开发者

How to set the color of UISearch Bar

开发者 https://www.devze.com 2023-03-31 13:52 出处:网络
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?

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 UI开发者_开发百科Search bar
sBar.tintColor = [UIColor lightGrayColor];

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

How to set the color of UISearch Bar


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号