![](/img/trans.png)
[英]Why is the top of a black translucent UIToolbar different from a black translucent UISearchBar, and how can I make them look the same?
[英]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.