I have an application with 4 tabs. Each tab is a UINavigationController. The 4 UINavigationBar tabs should look the same, have a custom background image, a custom backButton, and a custom right button that launches the function.
I would like to make these settings only once in my code, and not in every RootViewController.
I managed to create a custom background image by pasting this code into my appDelegate:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"MyNavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
But I was not able to configure the back and right buttons or specify an action for the right button.
Is there a way to do this in appDelegate, as well as for the background image?
Or should I do the setup in every RootViewController?
source
share