I have an appearance proxy that sets the barTintColor
property to green on UINavigationBar
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:54./255 green:165./255 blue:53./255 alpha:1]];
As needed I override this using appearanceWhenContainedIn:
[[UINavigationBar appearanceWhenContainedIn:[INFSearchViewController class], nil] setBarTintColor:[UIColor colorWithWhite:0.80 alpha:1]];
This works fine.
However when I present an MFMessageComposeViewController
it adheres to the UINavigationBar
proxy and looks like the following.
Which obviously looks terrible, I would prefer MFMessageComposeViewController
to not adhere to the proxy but attempting to do
[[UINavigationBar appearanceWhenContainedIn:[MFMessageComposeViewController class], nil] setBarTintColor:[UIColor whiteColor]];
has no affect.
What course of action should I take here?
The hacky way: set the appearance back to the default white, present the modal, set the appearance to styled when the modal returns.
Or, reverse your thinking. Leave the global appearance as the default. Then you can selectively apply the styled nav bar where appropriate.
If "where appropriate" ends up being 90% of the app, just set up a thin subclass of UIViewController (or whatever view controller you use a lot) and that use that where you want the appearance.
[[UINavigationBar appearanceWhenContainedIn:[MyStyledViewController class], nil]
setBarTintColor:[UIColor colorWithRed:54./255 green:165./255 blue:53./255 alpha:1]];
And in each .h file, set your view controller superclass to MyStyledViewController
rather than plain old UIViewController
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With