Reputation: 69
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.
Upvotes: 0
Views: 581
Reputation: 459
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)
Upvotes: 2