Reputation: 12499
I need to change the text color in an UISearchBar
text field. I tried the two answers in this post:
UISearchBar text color change in iOS 7
But the text remains in its default gray color. I set that code in the viewDidLoad
method. What can I be missing? Did somebody have this same problem?
Thanks
Upvotes: 5
Views: 3565
Reputation: 54888
// Get the instance of the UITextField of the search bar
UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
// Change search bar text color
searchField.textColor = [UIColor blueColor];
Upvotes: 2
Reputation: 546
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor blueColor]];
//This is done in Xcode 5.0 and its working btw i don't know whether it works with previous versions of Xcode or not....
// Also I wrote this method in viewDidLoad
Upvotes: 2