UITabBar外观不起作用

时间:2013-12-11 02:29:38

标签: ios uitabbar uitabbaritem

我正在尝试使用以下代码行选择更改UITabBarItem的色调颜色:

[[UITabBar appearance]setTintColor:[UIColor colorWithRed:89 green:216 blue:239 alpha:1]];

然而,当我选择TabBar时,色调颜色变为白色。

任何人都知道为什么?

谢谢!

4 个答案:

答案 0 :(得分:2)

在uicolor:RGB中,您需要将值除以255。

[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]

答案 1 :(得分:2)

尝试以下方法:

[[UITabBar appearance] setTintColor:[[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];

[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];//set rgb value if you want 

答案 2 :(得分:1)

将selectedImageTintColor属性设置为您的颜色。

答案 3 :(得分:1)

试试这个在你的app delegate的didFinishLaunching方法:

[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];

在iOS 7中使用:

[[UITabBar appearance] setTintColor:[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];