How Can I Set UISearchBar to Black Translucent Via Code?
I know how to do this using IB, but how can I do this with just code? OR do I manually have to do the RGB?
I have:
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectM开发者_高级运维ake(0.0, 0.0, 320.0, 44.0)];
You need to use the barStyle property and translucent properties together:
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
searchBar.barStyle = UIBarStyleBlack;
searchBar.translucent = YES;
I believe you can just do the following:
searchBar.barStyle = UIBarStyleBlackTranslucent;
Kool have fun :)
You should be able to do this via two properties in UISearchBar;
@property(nonatomic, retain) UIColor *tintColor
@property(nonatomic, assign, getter=isTranslucent) BOOL translucent
Set the tintColor
to black, and set translucent
to YES.
Check the reference for more info: http://developer.apple.com/library/iOS/#documentation/UIKit/Reference/UISearchBar_Class/Reference/Reference.html
Hope this does the trick!
精彩评论