Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar tinted like Contacts

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?

like image 216
Steven Fisher Avatar asked Aug 13 '09 03:08

Steven Fisher


2 Answers

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.

like image 157
Adam Woś Avatar answered Nov 15 '22 19:11

Adam Woś


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.

like image 36
Jonah Avatar answered Nov 15 '22 21:11

Jonah