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

liamnichols
  • 12,419
  • 2
  • 43
  • 62
  • Had you tried to set appearance before composer was shown ? – Leszek Zarna Oct 11 '13 at 16:58
  • @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 it – liamnichols Oct 11 '13 at 20:24
  • @LeszekŻarna did you run into something similar - I am stuck http://stackoverflow.com/questions/20768736/uibarbuttonitem-appearance-settintcolor-getting-lost-ios-7 – Sam B Dec 25 '13 at 03:33

1 Answers1

2

You can set the appearence directly on the MFMailComposeViewController

MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[MFMailComposeViewController.navigationBar setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];
Jacopo Berta
  • 265
  • 2
  • 14