Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController ignoring some of UIAppearance protocol in iOS 7

I have an iOS 7 only application that uses UIAppearance to style the UINavigationBar's throughout the app.

I have the following code in my AppDelegate:

[[UINavigationBar appearance] setBackgroundImage:redImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];

However the MFMailComposeViewController appears with the redImage background!

The documentation says the following:

Important: The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol.

So there is not reason that the above shouldn't work and I am 100% sure thatredImage and blueImage are different coloured images.

Has anyone else experienced this issue? I'm guessing it is a bug in iOS 7 but I haven't had time to check on iOS 6 (I'm getting these results by using an iPad 4).

like image 241
liamnichols Avatar asked Oct 11 '13 13:10

liamnichols


1 Answers

You can set the appearence directly on the MFMailComposeViewController

MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[MFMailComposeViewController.navigationBar setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];
like image 120
Jacopo Berta Avatar answered Oct 24 '22 21:10

Jacopo Berta