Roee84 Roee84 - 1 year ago 129
iOS Question

UITabBar icons text color

How can I change the text color of UITabBar (which is contained in UINavigationController if it's matters) ?
If I write this -

UITabBar.appearance().tintColor = UIColor.greenColor()

then the color would be green as expected, but if I write this -

UITabBar.appearance().tintColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0)

The text becomes invisible

The same goes for

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected) //red color

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(red: CGFloat(104), green: CGFloat(154), blue: CGFloat(26), alpha: CGFloat(1))], forState:.Selected) //invisible

Answer Source

Please try writing it like this:

UITabBar.appearance().tintColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download