ios8uitabbaruiappearance

UITabBar tint color not working on images


I have a UITabBar set up with Interface Buider and the image highlighting works correctly only if I don't set the global app tint color:

tab bar without tint color

When I set the global tint color of my app using

[[UIView appearance] setTintColor:[TAStyleKit tintColor]];

then all the tab images appear as selected.

enter image description here

Only when I click on the tab and go back again, they have the correct color. Note the "Weapons" tab which is here grey:

enter image description here

What am I doing wrong ?


Solution

  • EDIT: Never mind what I wrote before, looks like you just need to change the following...

    [[UIView appearance] setTintColor:[TAStyleKit tintColor]];
    

    To...

    [[UITabBar appearance] setTintColor:[TAStyleKit tintColor]];
    

    Notice that you were trying to change the appearance of UIView instead of UITabBar. I ran this in a project and it did the trick.

    enter image description here

    enter image description here

    Swift 4.0

    UITabBar.appearance().tintColor = UIColor.red or TAStyleKit.tintColor