Zhen
Zhen

Reputation: 12431

How to set the color of UISearch Bar

Can anyone advise me on how I can set the color of the UISearchbar such that it follows the color of that search bar used in the address book?

It has a light gray color and the cancel button is of a darker tone.

I tried the code:

//Ser color of UISearch bar
sBar.tintColor = [UIColor lightGrayColor];

But is unable to replicate the color and effect (of the button color).

enter image description here

Upvotes: 3

Views: 2887

Answers (1)

Sabby
Sabby

Reputation: 2592

You need to set the tint property of your search bar. e.g.

historySearchBar.tintColor=[UIColor colorWithRed:129.0/255.0f green:129.0/255.0f blue:130.0/255.0f alpha:.80];

This will change the color of your search bar.

Well right now you are using the gray color,which is the color of default search bar Try setting the other color. And you have also the option of setting up the search bar type like black, UIBarStyleBlackTranslucent. Enjoy

Upvotes: 3

Related Questions