In iOS 7, I been developing an app that uses the UITabBarController and I noticed that the tab bar items stay gray even tho I change the tint color of the tab bar. Is there any way to change the color of non-selected tab bar items?
6
votes
3 Answers
6
votes
To do this:: follow a simple approach..
Change tintColor as you want
Add a new set of images for unselected items and render them in original mode.
For more info, read through this link
6
votes
0
votes
Changing the tabBar.tintColor property is the right way to do it, however to make it work we need to tell iOS to ignore color properties of the UIImage in TabBarItem.
Hence write this code in your custom TabBarViewController's viewDidLoad()
for item in self.tabBar.items ?? [] {
item.selectedImage = item.selectedImage?.withRenderingMode(.alwaysTemplate)
item.image = item.image?.withRenderingMode(.alwaysTemplate)
}