I have the following code in viewWillAppear in my view controller.
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIImage *image = [UIImage imageNamed:@"navbar.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationController.navigationBar addSubview:imageView];
}
How do I clear the navigation bar background image that is already there before adding a new nav bar image as in the code above?
Also, how can I set a different navigation bar background image for each different controller the most efficient way possible? thanks!
In your viewWillAppear method, use the following call to set the background image of the navigation bar.
If your app supports landscape as well, you’ll also need to set the background image for the landscape navigation bar with a different height: