Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of UIAppearance when not needed?

In my AppDelegate I use UIAppearance to set my own NavigationBar with this code :

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav5.png"] forBarMetrics:UIBarMetricsDefault];

But some views of my application don't need it. How can I get rid of it so I may only use IB in concerned views ?

like image 925
Rob Avatar asked May 23 '12 22:05

Rob


1 Answers

You don't need to use the proxy. Just get the actual navigationBar, which should look different and set the colors directly on it.

[navigationBarInstance setTintColor:[UIColor blackColor]];
[navigationBarInstance setBackgroundImage:[UIImage imageNamed:@"nav5.png"] forBarMetrics:UIBarMetricsDefault];

You can also just set both values to nil, where you want the standard styles again. (tested by Ben Clayton).

[navigationBarInstance setTintColor:nil];
[navigationBarInstance setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
like image 133
calimarkus Avatar answered Oct 27 '22 11:10

calimarkus