1

Any idea how to set the UISearchBar textfield's background color separately from the search bar's tintcolor?

[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[XYNavigationController class]]].barTintColor = [UIColor redColor];

results in enter image description here

And even if you try:

[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class], [XYNavigationController class], [UINavigationBar class]]].layer.backgroundColor = [UIColor orangeColor].CGColor;

[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class], [XYNavigationController class], [UINavigationBar class]]].backgroundColor = [UIColor orangeColor];

[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class], [XYNavigationController class], [UINavigationBar class]]].tintColor = [UIColor orangeColor];

the textfield's background color won't change to orange. Is this a bug or something different needs to be done?

Thanks.

Zsolt
  • 3,648
  • 3
  • 32
  • 47

1 Answers1

4

For changing searchBar's text field background color, use UISearchBar.searchTextField.backgroundColor property added in iOS 13

XDev
  • 111
  • 7