如何更改a的文本颜色UISearchBar?
UISearchBar
您必须访问UITextFieldUISearchBar内部。您可以通过使用valueForKey("searchField")
UITextField
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