MFMailComposeViewController ignoring some of UIAppearance protocol in iOS 7
Asked Answered
J

1

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).

Jael answered 11/10, 2013 at 13:46 Comment(3)
Had you tried to set appearance before composer was shown ?Selfloading
@LeszekŻarna yeah, a hack to get around it is to set the global appearance just before I present it and then change it back just before I dismiss it.. however this seems impratical and I was wondering if there was a proper fix to itJael
@LeszekŻarna did you run into something similar - I am stuck #20769236Arnhem
G
2

You can set the appearence directly on the MFMailComposeViewController

MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[MFMailComposeViewController.navigationBar setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];
Gatehouse answered 5/2, 2014 at 18:28 Comment(1)
Not anymore at least.Windbag

© 2022 - 2024 — McMap. All rights reserved.