[英]Can't change tabbar tintColor with a custom color
我正在嘗試使用自定義顏色更改選項卡的顏色,但似乎沒有辦法...
我已經以這種方式為UIColor類定義了一個類別:
@implementation UIColor (UakariColor)
+(UIColor *) defaultUakariColor {
return [UIColor colorWithRed:237.0/255.0 green:28.0/255.0 blue:36.0/255.0 alpha:0];
}
@end
然后,我試圖以這種方式(在自定義標簽欄控制器中)用我的自定義顏色設置標簽欄的顏色:
//Change the color of the tabbar
if([[self tabBar] respondsToSelector:@selector(setTintColor:)])
[[self tabBar] setTintColor:[UIColor defaultUakariColor]];
但是,如果我改為設置標准顏色(例如redcolor),則它不起作用(標簽欄為black):
[[self tabBar] setTintColor:[UIColor redColor]];
它有效,並將顏色設置為紅色...
為什么使用自定義顏色不起作用? 這是一個錯誤嗎?
如果您set
alpha(opacity)
set
為0
那么它將like clear color
因此根據您的requirment
set
其set
為1
。 這樣做:
@implementation UIColor (UakariColor)
+(UIColor *) defaultUakariColor {
return [UIColor colorWithRed:(237.0/255.0) green:(28.0/255.0) blue:(36.0/255.0) alpha:1];
}
@end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.