In need a background image AND a title in my Navigation Bar. For the image I write a category:
@implementation UINavigationBar(MyNavigationBar)
- (void)setBackgroundImage {
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"navBarBackgrd.png"]];
[self addSubview: aTabBarBackground];
[self sendSubviewToBack: aTabBarBackground];
[aTabBarBackground release];
}
@end
I call this category in my AppDelegate and have background images in the whole application:
[navigationController.navigationBar setBackgroundImage];
Every ViewController has a title:
[self setTitle:@"MyTitle"];
But after setting the background image, I have a problem with the title.
In the first view every works, I see the background image and the title :-) But in the next view, the title disappears. Only the background image is visible. Maybe the title is under the image?
Technically it's possible to show both. With this trick it works:
Hide Navigation Bar BEFORE opening the next ViewController:
[self.navigationController setNavigationBarHidden:YES];
Show the Navigation Bar in the next ViewController:
[self.navigationController setNavigationBarHidden:NO];
Now, image AND title are visible, but this solution isn't the best ;-)