4
在iOS的7.x中,我们能够使用变化的UISearchBar文本颜色9+
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil]
setDefaultTextAttributes:@{NSForegroundColorAttributeName:myColor}];
但它得到了在IOS 9不赞成我所知道的唯一的解决办法 - 就是通过UISearchBar
子视图层次遍历,请查找UITextField
并更改其属性。但是,这种方式被认为是私有API使用
我们有法律办法改变的UISearchBar文本颜色的iOS 9.x中?
只是因为它是过时,并不意味着你不能使用它(见http://stackoverflow.com/a/ 4133201/4062250如果你被警告所困扰)。 – deadbeef
根本没有这样的方法,至少在Swift中'UIAppearance'协议不包含这样的方法:https://gist.github.com/OgreSwamp/d554536d8f747d618483 – OgreSwamp
没想到那个......也许这会帮助:http://stackoverflow.com/questions/24136874/appearancewhencontainedin-in-swift – deadbeef