Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMessageComposeViewController appearance iOS 7

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.

enter image description here

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?

like image 811
Chris Wagner Avatar asked Sep 26 '13 00:09

Chris Wagner


1 Answers

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.

like image 67
gregheo Avatar answered Nov 17 '22 09:11

gregheo