【发布时间】:2012-06-15 14:48:36
【问题描述】:
我正在尝试使用自定义颜色更改标签栏的颜色,但似乎没有办法做到这一点......
我以这种方式为 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 :
[[self tabBar] setTintColor:[UIColor redColor]];
它可以工作,并将颜色设置为红色......
为什么自定义颜色不起作用?是BUG吗?
【问题讨论】:
标签: objective-c ios cocoa-touch ios5