0

How can I change the text and icon colors for UITabBar and UITabBarItems in XCODE 7 using SWIFT 2? The default gray text seems dim and hard to read for unselected tabbar items.

i want the text and icons white when inactive and this colour: #600c77 (purple) when active.

user5168832
  • 69
  • 1
  • 6
  • 1
    Possible duplicate of [Default tab bar item colors using swift Xcode 6](http://stackoverflow.com/questions/25052729/default-tab-bar-item-colors-using-swift-xcode-6) – Michal Jan 14 '16 at 17:33

1 Answers1

2

For your icon:

yourTabBar.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "tab_icon_normal"), selectedImage: UIImage(named: "tab_icon_seelcted"))

For your text:

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.YOURCOLOR()], forState:.Normal)

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.YOURCOLOR()], forState:.Selected)
Mitesh Mistri
  • 439
  • 2
  • 8