0

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.

Charles
  • 50,943
  • 13
  • 104
  • 142
mhbdr
  • 753
  • 2
  • 10
  • 26

1 Answers1

0

You can use this appearanceWhenContainedIn: to show different navigationBar when displayed in UITableViewController for more information see here

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
  • Ok I tried appearanceWhenContained in, but I still only see "NavBarNoText.png" Do I put the appearanceWhenContained in code in the customizeAppearance method in AppDelegate.m, or should I put it in TableViewController.m? – mhbdr May 24 '12 at 23:44
  • you have to give the class name for your TableViewController's class – The iOSDev May 25 '12 at 05:35