我需要更改UISearchBar
文本字段中的文本颜色。我尝试了这篇文章中的两个答案:
UISearchBar text color change in iOS 7
但是文本仍然保持默认的灰色。我在viewDidLoad
方法中设置了该代码。我可能遗漏了什么?有人遇到过同样的问题吗?
谢谢
我需要更改UISearchBar
文本字段中的文本颜色。我尝试了这篇文章中的两个答案:
UISearchBar text color change in iOS 7
但是文本仍然保持默认的灰色。我在viewDidLoad
方法中设置了该代码。我可能遗漏了什么?有人遇到过同样的问题吗?
谢谢
[[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
// 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];
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor blueColor]];
然后它就起作用了... 那么有可能同时改变文本框中小搜索图标的颜色吗? - AppsDevUISearchBar
文档。 - rmaddy