I have tabBar with 5 items. My app start on first item and all has white color. When I tap on another item nothing change - this is clear, but is possible that when I tap on second item all the items change color to black or when I tap on third item their color change back to white?
Asked
Active
Viewed 126 times
0
-
Do you implement **func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem)** – Shehata Gamal Aug 30 '18 at 16:10
-
This is it! Thank you for good way – Cris Lowiec Aug 30 '18 at 17:37
1 Answers
0
Yes, to achieve it you have to options depending on your setup, in both cases you have to implement the following method func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem):
If you are using a ViewController, it will have to implement the UITabBarController and UITabBarControllerDelegate. You will have to set the delegate property to self, you have to do it in the
viewDidLoad
method:self.delegate = self
If you are using a Tab Bar Controller Scene in your Storybard), create an instance of a UITabBarController class, in my example TabViewController, and set it as a custom class in your Tab View Controller.
Next, in both cases you will have to implement the following method:
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem)
self.tabBar.tintColor = UIColor.red
}

Miquel Rigo
- 61
- 1
- 3