I'm using UIAppearance in iOS 5 to create a custom UINavigationBar. I use the following code (inside AppDelegate.m) to give all of the navigation bars the same background
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBarNoText.png"] forBarMetrics:UIBarMetricsDefault];
I'd like to be able to use 1 navbar "NavBarWithText.png" for only 1 TableViewController, while I use the NavBarNoText.png as the background for all of the other navigation bars except for said TableViewController. Does anyone know if this is possible? I know Instagram does something like it, with the home tab using a different navigation bar than all of the other tabs.
I've tried using this separately in the ViewDidLoad method in each separate class, but it doesn't seem to work. I get the single view to have a different background at first, but it changes back to the common background after I switch a view.
-(void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBarWithText.png"] forBarMetrics:UIBarMetricsDefault];
}
For the single view
-(void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBarNoText.png"] forBarMetrics:UIBarMetricsDefault];
}
For all of the other views.
You can use this appearanceWhenContainedIn:
to show different navigationBar when displayed in UITableViewController
for more information see here