6
votes

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?

3
This tutorial can be useful for you: captechconsulting.com/blog/steven-beyers/… - Robert
Above link does not work. @roher. - Arpit B Parekh

3 Answers

6
votes

To do this:: follow a simple approach..

  1. Change tintColor as you want

  2. Add a new set of images for unselected items and render them in original mode.

For more info, read through this link

6
votes

To sets the tint color globally for the app, you need to add below code In app delegate didFinishLaunchingWithOptions: method:

[[UITabBar appearance] setTintColor:[UIColor colorWithRed:13.0/255.0 green:116.0/255.0 blue:128.0/255.0 alpha:1.0]];
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)
}