[英]Can't change tabbar tintColor with a custom color
i'm trying to change the color of the tabbar with a custom color but seems that there is no way to do it ... 我正在尝试使用自定义颜色更改选项卡的颜色,但似乎没有办法...
I have defined a category for the UIColor class in this way : 我已经以这种方式为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
I then i'm trying to set the color of the tabbar with my custom color in this way (in the custom tab bar controller) : 然后,我试图以这种方式(在自定义标签栏控制器中)用我的自定义颜色设置标签栏的颜色:
//Change the color of the tabbar
if([[self tabBar] respondsToSelector:@selector(setTintColor:)])
[[self tabBar] setTintColor:[UIColor defaultUakariColor]];
but it doesn't work (the tab bar is black ), if i instead set a standard color like redcolor : 但是,如果我改为设置标准颜色(例如redcolor),则它不起作用(标签栏为black):
[[self tabBar] setTintColor:[UIColor redColor]];
It works, and set the color to red ... 它有效,并将颜色设置为红色...
Why with a custom color doesn't work ? 为什么使用自定义颜色不起作用? Is it a BUG ?
这是一个错误吗?
if u have set
alpha(opacity)
to 0
then it will be like clear color
so it as per your requirment
u set
it to 1
. 如果您
set
alpha(opacity)
set
为0
那么它将like clear color
因此根据您的requirment
set
其set
为1
。 So do this: 这样做:
@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.