0
我將搜索欄的佔位符顏色更改爲藍色,文本顏色更改爲白色。正常情況正常工作。UISearch欄文字顏色問題
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDefaultTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor colorWithRed:131/255.0 green:169/255.0 blue:202/255.0 alpha:1.0] ];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:[UIColor colorWithRed:42/255.0 green:93/255.0 blue:134/255.0 alpha:1.0]];
問題 當我設置文本
self.searchbar.text = @"Some text";
在搜索欄中顯示的文本採取佔位符顏色即藍色,但我想它採取白色。