UISearchBar tinted like Contacts
-
13-09-2019 - |
Question
The UISearchBar
in my UITableView
header is the strong color.
The TableSearch
uses the more subtle code, but I'm not sure how it's doing it. I've looked at the TableSearch example code. Specifically, I don't see tintColor
being used anywhere in this example. I don't see opacity or alpha used, either.
How does the TableSearch
example do this? Can anyone explain it?
Solution
According to the documentation, there is a tintColor
property on the UISearchBar
class.
In the TableSearch example the search bar is defined and loaded in the MainView.xib. If you want to change its tintColor or style, just do it in the xib and it will be loaded into the application.
OTHER TIPS
You can set the UISearchBar to any color you like using:
self.mySearchBar.tintColor = [UIColor colorWithRed:153/255.0 green:102/255.0 blue:51/255.0 alpha:1.0];
In this example the first number in the fractions are the RGB values. Just find the RGB color you want and fill in the values here.
I thought i'd mention that the alpha value for the tint colour does not seem to do anything. It always displays as alpha 1.0 value, and in interface builder, it does not let you adjust the opacity value.