Search code examples
objective-cxcode4.2appearance

Appearance in Xcode 4.2 doesn't work


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


Solution

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