0

We can set UITabBar item color for the selected state with property tintColor, but how can I set the tintColor for the a tab bar item item in the unselected state?

psobko
  • 1,548
  • 1
  • 14
  • 24
韩胜辉
  • 3
  • 1
  • 1
    possible duplicate of [Unselected UITabBar color?](http://stackoverflow.com/questions/11512783/unselected-uitabbar-color) – psobko Sep 28 '15 at 01:31
  • 1
    possible duplicate of [Change tintColor of unselected UITabBarController item title and background image iOS 8](http://stackoverflow.com/questions/26551458/change-tintcolor-of-unselected-uitabbarcontroller-item-title-and-background-imag) – rmaddy Sep 28 '15 at 02:05

1 Answers1

0

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]];

[self calculateFolderSize]; 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.

May be it will help you.

princ___y
  • 1,089
  • 1
  • 9
  • 27
Maulik shah
  • 1,664
  • 1
  • 19
  • 45
  • but in iOS8 the property selectedImageTintColor is deprecated ,and it suggest us to use tintColor to instead,so the first line will set the selected color-red not the unselected,you can test it use a iOS8 sumulator – 韩胜辉 Sep 28 '15 at 04:04
  • Refer this link http://stackoverflow.com/questions/26105507/change-uitabbar-tint-colors-from-more-menu-in-ios8 – Maulik shah Sep 28 '15 at 04:06