自定义UITabBar未选择项目的颜色

时间:2015-06-10 10:43:45

标签: swift uitabbar uitabbaritem

我正在尝试更改未选中的UITabBarItems的默认灰色。我设法改变了文字而不是图像。

enter image description here

TabBar.appearance().barTintColor = UIColor(red: 86.0/255.0, green: 132.0/255.0, blue: 208.0/255.0, alpha: 1.0)

var normalTint: UIColor = UIColor.whiteColor()

TabBar.appearance().tintColor = UIColor.whiteColor()

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint,NSFontAttributeName: UIFont(name: "Arial", size: 13)!], forState: UIControlState.Normal)

3 个答案:

答案 0 :(得分:13)

iOS 10 |斯威夫特3

Trie

答案 1 :(得分:3)

您可以使用 .AlwaysOriginal

tabBarItem.selectedImage = UIImage(named: "first-selected")!.imageWithRenderingMode(.AlwaysOriginal)

答案 2 :(得分:3)

  • 如果您想通过Storyboard将未选中的图标设置为特定颜色。
  • 您可以通过“用户定义的运行时属性”来执行此操作,而无需添加代码。 enter image description here
相关问题