0

I added this code in my AppDelegate in didFinishLaunchingWithOptions method:

[[UINavigationBar appearance]setBackgroundColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];

[[UITabBar appearance] setBackgroundColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];

But NavigationBar and TabBar didn't change their color. What I have done wrong? Thanks

SmartTree
  • 1,381
  • 3
  • 21
  • 40
  • See also: [iOS 5 UINavigationBar appearance setBackgroundImage does not do work](http://stackoverflow.com/questions/7855365/ios-5-uinavigationbar-appearance-setbackgroundimage-does-not-do-work) – PengOne Jan 10 '12 at 19:29
  • Yes, already fixed it, thanks! Now it works perfectly. But what about UITabBar, it doesn't change its color like NavBar. Dont you know why? – SmartTree Jan 10 '12 at 20:41

1 Answers1

1

Use setTintColor: instead of setBackgroundColor:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];
jonkroll
  • 15,682
  • 4
  • 50
  • 43
  • Ohh...right, crazy mistake. Thanks! But in this case, only NavigationBar changes it's color, and TabBar stills black. Dont you know why that happens? – SmartTree Jan 10 '12 at 20:36
  • Not sure, but you could try [this](http://www.alexcurylo.com/blog/2010/06/04/tip-uitabbar-tint/) technique. – jonkroll Jan 10 '12 at 21:23
  • Oh, I found out why it doesnt work. My `alpha` color was 0.0 :D – SmartTree Jan 10 '12 at 22:23