Reputation: 129
I have created a ViewController embedded in a navigation controller which automatically creates a UINavigationBar. Then i've added a UITabBar to the bottom. How can i change the standard color of these.
i've tried this, but does not change the color:
UIColor * color = [UIColor colorWithRed:248/255.0f green:243/255.0f blue:240/255.0f alpha:1.0f];
UIColor * navColor = [UIColor colorWithRed:176/255.0f green:189/255.0f blue:197/255.0f alpha:1.0f];
self.navigationController.navigationBar.tintColor = navColor;
[[UITabBar appearance] setBackgroundColor:color];
[self.navigationController.navigationBar setBackgroundColor:navColor];
Upvotes: 0
Views: 494
Reputation: 6990
Setting the appearance of controls with UIAppearance
only takes effect the next time a control of that type is created. So if you're setting the appearance after creating your navigationBar and tabBar (which is probably the case if they're created in a storyboard), the appearance won't take effect.
Try calling your appearance code from application:didFinishLaunchingWithOptions:
in your AppDelegate (I'd recommend creating a Themer
class which is responsible just for setting appearances - you could then create and use this from your AppDelegate), or otherwise set your navigationBar and tabBar appearance directly in your storyboard.
Upvotes: 1