How can I change the text color of a UISearchBar
?
Try this: UITextField *searchField = [searchbar valueForKey:@"_searchField"]; field. textColor = [UIColor redColor]; //You can put any color here.
You have to access the UITextField
inside the UISearchBar. You can do that by using valueForKey("searchField")
var textFieldInsideSearchBar = yourSearchbar.valueForKey("searchField") as? UITextField textFieldInsideSearchBar?.textColor = yourcolor
Swift 3 update
let textFieldInsideSearchBar = yourSearchbar.value(forKey: "searchField") as? UITextField textFieldInsideSearchBar?.textColor = yourcolor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With