我知道如何使用IB来做到这一点,但我怎样才能用代码来做到这一点?或者我手动必须做RGB?如何设置UISearchBar黑色半透明代码?
我:
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
我知道如何使用IB来做到这一点,但我怎样才能用代码来做到这一点?或者我手动必须做RGB?如何设置UISearchBar黑色半透明代码?
我:
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
你应该能够通过在的UISearchBar两个属性做到这一点;
@property(nonatomic, retain) UIColor *tintColor
@property(nonatomic, assign, getter=isTranslucent) BOOL translucent
设置tintColor
为黑色,并设置translucent
为YES。
希望这样做的伎俩!
您需要使用barStyle财产和半透明特性一起:
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
searchBar.barStyle = UIBarStyleBlack;
searchBar.translucent = YES;
我相信你可以做到以下几点:
searchBar.barStyle = UIBarStyleBlackTranslucent;
库尔玩得开心:)