问题描述
我需要将UITabBar的选择颜色从默认蓝色更改为红色。我们如何做到这一点。
I need to change the selection color of UITabBar from default blue to red. How do we do this.
推荐答案
你可以通过为你的UITabBar设置一个tintColor属性
You can do this by setting a "tintColor" attribute (Key Path) for you UITabBar.
- 在文档大纲中选择UITabBar。
- 在实用程序区域中选择身份检查器。
- 单击+ inUser Defined Runtime Attributes。
- 添加类型为Color的颜色的tintColor键路径和所需的颜色。
- Select the UITabBar in the document outline. (NOT the Controller with the yellow icon.)
- Select Identity Inspector in the Utilities area.
- Click the + in "User Defined Runtime Attributes."
- Add a "tintColor" Key Path of type "Color" and the color you want.
这应该做。您可以根据下面的屏幕截图检查它。
This should do it. You can check it against the screenshot below.
更多:
UITabBar的Identity Inspector中有一个Tint属性,我相信它会做同样的事情,但显然它什么都不做。它的默认值是精确的默认填充颜色,当选择UITabBarItem时,所以我的猜测是它会在稳定版本Xcode 7中修复。手指交叉。
More on this:There's a "Tint" attribute in Identity Inspector of UITabBar which I believed would do the exact same thing but apparently, it does nothing. It's default value is the exact default fill color when a UITabBarItem is selected, so my guess is it would be fixed in the stable release Xcode 7. Fingers crossed.
这篇关于如何更改UITabBar选择颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!