简体   繁体   English

在iOS 9中更改UITabBarItem的色调颜色?

[英]Changing UITabBarItem's Tint Color in iOS 9?

I can't seem to change the tint color for UITabBarItem 's in iOS 9. I'm using objective-c and have tried using titleTextAttributes programmatically, and runtime attributes in storyboard as well. 我似乎无法更改iOS 9中UITabBarItem的颜色。我使用的是Objective-c,并尝试以编程方式使用titleTextAttributes以及情节提要中的运行时属性。 I've read through the documentation, but can't seem to figure this out. 我已经阅读了文档,但似乎无法弄清楚。 In fact I've even created a separate selectedState image, but again, it still tints it system blue. 实际上,我什至创建了一个单独的selectedState图像,但同样,它仍将系统设置为蓝色。

You can use the appearance proxy like this: 您可以像这样使用外观代理:

[[UITabBar appearance]setTintColor:[UIColor black]];

This is working for me on iOS8 and iOS9. 这对我在iOS8和iOS9上有效。 I have it in my app delegate - but you can put it in a base class if you like. 我在我的应用程序委托中有它-但是您可以根据需要将其放在基类中。

您可以访问选项卡栏控制器的TabBar属性并设置色调颜色。

[youTabbarcontroller.tabBar setTintColor:[UIColor anycolor]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM