This is my code to change the color of my app's tab bar and navigation bar:
UIColor* color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blue.jpeg"]];
//set colors
[[UINavigationBar appearance] setTintColor:color];
[[UITabBar appearance] setTintColor:color];
Yet only the tab bar tint color changes; the navigation bar stays black. Why does setTintColor:
work for the tab bar but not the navigation bar?
Edit: Interestingly enough, when testing on a real device (an iPhone 4 running iOS 5.0.1) neither the tab bar nor the navigation bar's color is changed; both stay black. On the simulator at least the tab bar changes... any explanation for this behavior? Thanks!
Edit 2: Here's part of my code in applicationDidFinishLaunching:
UIColor* color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blue.jpeg"]];
//create navigation controllers
firstNavigationController = [[UINavigationController alloc]
initWithRootViewController:viewController1];
[[firstNavigationController navigationBar] setTintColor:color];
//[[firstNavigationController navigationBar] setBarStyle:UIBarStyleBlack];
secondNavigationController = [[UINavigationController alloc]
initWithRootViewController:viewController2];
[[secondNavigationController navigationBar] setTintColor:color];
//[[secondNavigationController navigationBar] setBarStyle:UIBarStyleBlack];
thirdNavigationController = [[UINavigationController alloc]
initWithRootViewController:viewController3];
[[thirdNavigationController navigationBar] setTintColor:color];
//[[thirdNavigationController navigationBar] setBarStyle:UIBarStyleBlack];
fourthNavigationController = [[UINavigationController alloc]
initWithRootViewController:viewController4];
[[fourthNavigationController navigationBar] setTintColor:color];
//[[fourthNavigationController navigationBar] setBarStyle:UIBarStyleBlack];
//create tab bar controller
self.tabBarController = [[UITabBarController new] autorelease];
self.tabBarController.delegate = self;
//set controllers
self.tabBarController.viewControllers = [NSArray
arrayWithObjects:firstNavigationController, secondNavigationController,
thirdNavigationController, fourthNavigationController, nil];
From lots more digging, I have learned that setting the tintColor property to a color made from an image is considered a 'hack'. Only RGB colors are supported and expected to work properly for this property. So there you have it. Because of the NDA I can't give any more details, but once iOS 6 is public, I'll try to update this.