Question

To set the navigation bar background the the entire application I have this code in app delegate:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];

However I want to have a different background for the initial view, actually its the same but has a custom font and logo init. I tried settings this:

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar-start.png"] forBarMetrics:UIBarMetricsDefault];

But this applied the change for the entire application. I am developing for ios7. How can I set a different background just for the initial view?

Was it helpful?

Solution

The navigationbar is common across all views in a navigation controller. So if you want to apply an image only for a single view, you can include the second code fragment in viewWillAppear of the concerned viewcontroller, and reset the image to the original one in viewWillDisappear

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top