How to change item color in TabBar in swift 3?

I have a TabBar in my project, and when the user selects an item, that item will be disabled, but the color will change too! I want the color to be the same as the color of the other elements in the TabBar I used

item.isEnabled = false 

for the disable parameter, but this code here will not work for this element

  override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.tabBar.barTintColor = UIColor.init(red: 126/255, green: 0/255, blue: 64/255, alpha: 1.0) if #available(iOS 10.0, *) { self.tabBar.unselectedItemTintColor = UIColor.white self.tabBar.unselectedItemTintColor = UIColor.white } else { // Fallback on earlier versions } UITabBar.appearance().tintColor = UIColor.white } 
+1
source share
1 answer

Try this code -

 UITabBar.appearance().tintColor = UIColor.gray UITabBar.appearance().unselectedItemTintColor = UIColor.gray 

Hope this helps!

+2
source

All Articles