Reputation: 43
I'm using de following code for placing an image on the background of the UINavigation Bar:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_background_login.png"] forBarMetrics:UIBarMetricsDefault];
In iOS 7 works like a charm but when I try it in the same simulator device but with iOS 8 the background image doesn't show.
There is some new code for iOS 8? I can't find anything on the net.
UPDATE:
I've discovered one of the most weird behaviors I've ever seen. When I show and later dismiss a modalView, then the Background Image of the UINavigationBar appears.
For more information: I'm loading the image in the viewDidLoad.
Any thoughs?
Upvotes: 3
Views: 4590
Reputation: 14413
Using [UINavigationBar appearance]
to set the UINavigationBar background globally is correct. But please note that the appearance affects only the future instances but not the already created ones. Try to place the set appearance code some place before your UINavigationConroller is created. it should still work.
Upvotes: 2
Reputation: 1043
Try this it worked for me:-
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_background_login.png"] forBarMetrics:UIBarMetricsDefault];
Upvotes: 5