小编典典

如何更改UISearchBar搜索文本的颜色?

swift

如何更改a的文本颜色UISearchBar


阅读 474

收藏
2020-07-07

共1个答案

小编典典

您必须访问UITextFieldUISearchBar内部。您可以通过使用valueForKey("searchField")

var textFieldInsideSearchBar = yourSearchbar.valueForKey("searchField") as? UITextField

textFieldInsideSearchBar?.textColor = yourcolor

Swift 3更新

let textFieldInsideSearchBar = yourSearchbar.value(forKey: "searchField") as? UITextField

textFieldInsideSearchBar?.textColor = yourcolor
2020-07-07