since I updated to xcode 4.2 and iOS 5 following code has no effect:
@implementation UINavigationBar (CustomNavBarBG)
-(void)drawRect:(CGRect)rect{
UIImage *image = [UIImage imageNamed:@"navbar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = [UIColor colorWithRed:124/255.0 green:177/255.0 blue:55/255.0 alpha:1.0];
}
@end
@implementation MyAppDelegate
//....
This should apply a background image and color to the navigation bar. But since the update I get the default blue color. I use the three20 framework in my project.
Any idea why this does not work? How can I set the background image for all navigation bars at one place and not in every view controller?
Try setting:
[[UINavigationBar appearance] setBackgroundImage:myImage forBarMetrics:UIBarMetricsDefault];
in your - (void) applicationDidFinishLaunching:(UIApplication *)application
EDIT: Seems helpfull too:
[[UINavigationBar appearance] setTintColor:myColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With