How to get rid of UIAppearance when not needed?
Asked Answered
U

1

9

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 ?

Uncial answered 23/5, 2012 at 22:9 Comment(0)
G
12

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];
Germainegerman answered 23/5, 2012 at 22:13 Comment(3)
Setting the background image and colors to nil does indeed set the styles back to the default. Tested.Wymore
Doesn't work on MFMailComposeViewController instance (See alpha.app.net/stuffmc/post/5028278)Ravenous
and so you did downvote? its a general question here, not about the mailcomposer..Germainegerman

© 2022 - 2024 — McMap. All rights reserved.