Question

G'day All

This is a small detail but it does affect the professional finish of my app.

My app follows the pattern of a tab bar with a navigation bar on each tab with more than 5 tabs hence a "More" item. I have a custom tint applied to the navigation bar but I haven't been able to find a way to access the navigation bar of the "More" item to set the tint on that. Can anyone tell me how?

Update...

Following the suggestion of a category on UINavigationBar I used this code...

@implementation UINavigationBar (UINavigationBar_Additions)

- (void)drawRect:(CGRect)rect {
    UIColor *color = [UIColor colorWithRed:0.862745098039216
                                     green:0.568627450980392
                                      blue:0.098039215686275
                                     alpha:1];
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
    CGContextFillRect(context, rect);
    [self setBarStyle:UIBarStyleBlack];
    [self setTintColor:color];
}

@end

Aside from Apple's warning (for reasons that seem to make sense to me) about not overriding hidden methods like this it also loses the gradient on the UINavigationBar & I'd rather keep that which my current approach of setting the tint in viewDidLoad does.

Any suggestions as to how I can have my cake & eat it too.

TIA, Pedro :)

Was it helpful?

Solution

It has been covered before on StackOverflow, which points to this blog, but the answer is to do the following:

tabBarController.moreNavigationController.navigationBar.tintColor =
[UIColor orangeColor];

OTHER TIPS

Add a category to UINavigationBar and override -drawRect:? (You can then do fun things like drawing an image instead...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top