0

I am trying to change the tint color of the UITabBarItem when it is selected with this line of code:

[[UITabBar appearance]setTintColor:[UIColor colorWithRed:89 green:216 blue:239 alpha:1]];

However when I select the TabBar the tint color becomes white.

Anyone know why?

Thank you!

Abdullah Shafique
  • 6,878
  • 8
  • 35
  • 70

4 Answers4

2

In uicolor:RGB, you need to devide the value of 255.

[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]
Horst
  • 1,733
  • 15
  • 20
2

Try the below:

[[UITabBar appearance] setTintColor:[[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];

[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];//set rgb value if you want 
Dhaval Bhadania
  • 3,090
  • 1
  • 20
  • 35
1

set the selectedImageTintColor property to your color.

Wubao Li
  • 1,728
  • 10
  • 13
1

Try this In your app delegate's didFinishLaunching method:

[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];

In iOS 7 use:

[[UITabBar appearance] setTintColor:[UIColor colorWithRed:89/255.0f green:216/255.0f blue:239/255.0f alpha:1]];
the1pawan
  • 1,194
  • 9
  • 26