Ios7 UISearchbar BartinColor取消按钮不可见
我尝试使用如下代码将UISearchbar的条形图颜色设置为一种颜色,将tintColor(光标和取消按钮)设置为另一种颜色:Ios7 UISearchbar BartinColor取消按钮不可见,ios7,uisearchbar,tintcolor,bartintcolor,Ios7,Uisearchbar,Tintcolor,Bartintcolor,我尝试使用如下代码将UISearchbar的条形图颜色设置为一种颜色,将tintColor(光标和取消按钮)设置为另一种颜色: searchbar.barTintColor = color1; searchbar.tintColor = color2; 颜色应用正确 问题是:取消按钮的文本不可见,但如果在情节提要中尝试相同的操作(将batTintColor和tintColor应用于UISearchbar),则一切正常 我注意到取消按钮只有在其状态为“正常”时才可见,因此我找到了解决问题的代码,
searchbar.barTintColor = color1;
searchbar.tintColor = color2;
颜色应用正确
问题是:取消按钮的文本不可见,但如果在情节提要中尝试相同的操作(将batTintColor和tintColor应用于UISearchbar),则一切正常 我注意到取消按钮只有在其状态为“正常”时才可见,因此我找到了解决问题的代码,但我认为这不是预期的方法
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor]} forState:UIControlStateNormal];