Damien Romito Damien Romito - 2 months ago 15
Objective-C Question

How to change the color of the UISearchBar Icon?

I don't know how to modify the original

searchIcon
's color.

enter image description here

Answer

Use this method. (Link to documentation.)

- (void)setImage:(UIImage *)iconImage
forSearchBarIcon:(UISearchBarIcon)icon
           state:(UIControlState)state;

Example Code:

[searchBar setImage:[UIImage imageNamed:@"SearchIcon"]
   forSearchBarIcon:UISearchBarIconSearch
              state:UIControlStateNormal];