Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationBar appearance override in iOS 5

I have had the following code:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsLandscapePhone];
    [[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.72 alpha:1.0]];

But now I want to have one place in my app where I want the navbar to be a different color than this universal color I've set throughout the app. How can I change this for this particular settings only. Is it possible?

like image 480
adit Avatar asked Feb 25 '12 20:02

adit


1 Answers

You can call setBackgroundImage on the instance of the navigation bar as well.

See this related post:

Custom UITabBar background image not working in iOS 5 and later

You should also condition it on whether it responds to that selector:

if ([navBar respondsToSelector:@selector(setBackgroundImage:)])
{
    [navBar setBackgroundImage:[UIImage imageNamed:@"tabbar_brn.jpg"]];
}
else
{
    // ios 4 code here
}
like image 157
bryanmac Avatar answered Oct 14 '22 12:10

bryanmac