Change tint of navigationBar and toolBar in a Popovercontroller with Navigationcontroller as view
I have a UINavigationController as my UIPopoverController's main view. I want to change the color tint of the navigationBar and toolBar but can't seem to get it to work.
Can anyone point me in the correct direction?
Here is the code I have in place that is not working. Where Color Scheme = [UIColor colorWithRed:0.228 green:0.307 blue:0.492 alpha:1.000] Here is the result from the NSLOG statement: Color Scheme = UIDeviceRGBColorSpace 0.228 0.307 0.492 1
self.navController = [[UINavigationController alloc]
initWithRootViewController:serversMenu];
NSLog(@"Color Scheme = %@", self.appDelegate.开发者_如何转开发colorScheme);
self.navController.navigationBar.tintColor = self.appDelegate.colorScheme;
self.navController.toolbar.tintColor = self.appDelegate.colorScheme;
self.navController.navigationBar.translucent = YES;
UIPopoverController *poc = [[UIPopoverController alloc] initWithContentViewController:self.navController];
poc.delegate = serversMenu;
serversMenu.mainPopOver = poc;
[poc release];
Thanks,
Rob
This works just fine:
AboutViewController *avc = [[AboutViewController alloc] init];
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:avc] retain];
avc.navigationController.navigationBar.tintColor = [UIColor greyColor]; /* or whatever color you choose */
toolbar.tintColor = [UIColor greyColor];
Depends on how you choose to create your UIPopoverController
This is a bug ... and here's your fix ... Create a subclass of UINavigationBar with this as it's only new method:
- (void)setTintColor:(UIColor *)tintColor
{
// Bug workaround.
[super setTintColor:[self tintColor]];
}
I'm going to venture out on a limb and say this is a bug in iOS 4.2.x's PopOver/SplitView update ... I say "bug" because I had it set up pretty much like you and under 4.1 it works as expected. Now, under 4.2.x, it initially looks good, but once you open the masterView in a popover and then rotate back to the dual split, the masterView's navbar is silver (ios default), and no amount of hammer beating will get the masterView's navbar tint reset to your color scheme ...
I'm not exactly how to best put this in the form of a bug report, given that I don't fully understand it myself. But it used to work and we're not doing anything crazy!
精彩评论