Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBar tint in iOS 7

How can i specify the tint of images when a tab is selected and unselected?

I have tried this but it doesnt work:

[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];

This makes the selected image tint red(not green) and unselected tint gray (not red).

like image 807
0xSina Avatar asked Oct 07 '13 17:10

0xSina


1 Answers

You can set the tint color for selected and unselected tab bar buttons like this:

[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];

The first line sets the unselected color - red in this example - by setting the UIView's tintColor when it's contained in a tab bar. Note that this only sets the unselected image's tint color - it doesn't change the color of the text below it.

The second line sets the tab bar's selected image tint color to green.

like image 141
Josh Brown Avatar answered Sep 24 '22 05:09

Josh Brown