我需要更改UISearchBar
文本字段中的文字颜色。我在这篇文章中尝试了两个答案:
UISearchBar text color change in iOS 7
但文字保持默认的灰色。我在viewDidLoad
方法中设置了该代码。我能错过什么?有人有同样的问题吗?
由于
答案 0 :(得分:2)
[[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
答案 1 :(得分:2)
// 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];