Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios7 UISearchbar BartinColor取消按钮不可见_Ios7_Uisearchbar_Tintcolor_Bartintcolor - Fatal编程技术网

Ios7 UISearchbar BartinColor取消按钮不可见

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

我尝试使用如下代码将UISearchbar的条形图颜色设置为一种颜色,将tintColor(光标和取消按钮)设置为另一种颜色:

searchbar.barTintColor = color1;
searchbar.tintColor = color2;
颜色应用正确


问题是:取消按钮的文本不可见,但如果在情节提要中尝试相同的操作(将batTintColor和tintColor应用于UISearchbar),则一切正常

我注意到取消按钮只有在其状态为“正常”时才可见,因此我找到了解决问题的代码,但我认为这不是预期的方法

 [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil]    setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor]} forState:UIControlStateNormal];