繁体   English   中英

如何通过代码将UISearchBar设置为黑色半透明?

[英]How Can I Set UISearchBar to Black Translucent Via Code?

我知道如何使用IB做到这一点,但是如何仅用代码就可以做到这一点? 还是我必须手动执行RGB?

我有:

UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];

您需要同时使用barStyle属性和半透明属性:

UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
searchBar.barStyle = UIBarStyleBlack;
searchBar.translucent = YES;

我相信您可以执行以下操作:

searchBar.barStyle = UIBarStyleBlackTranslucent;

库尔玩得开心:)

您应该能够通过UISearchBar中的两个属性来执行此操作;

@property(nonatomic, retain) UIColor *tintColor
@property(nonatomic, assign, getter=isTranslucent) BOOL translucent

tintColor设置为黑色,并将translucent设置为YES。

检查参考以获取更多信息: http : //developer.apple.com/library/iOS/#documentation/UIKit/Reference/UISearchBar_Class/Reference/Reference.html

希望这可以解决问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM