I didn't find the way to remove the translucent effect (iOS 7) to the UINavigationBar of MFMailComposeViewController. No problem for all other UINavigationBars in my app.
I tried this without success:
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.navigationBar.translucent = NO;
Any idea ?
You need to do three things to make a navigation bar transparent. Set background image to non-nil empty image ( UIImage() ). Set shadow image to non-nil empty image ( UIImage() ). Set isTranslucent to true .
A Boolean value that indicates whether the navigation bar is translucent.
A bit late, but for whoever comes across this post:
By default, the MFMailComposeViewController's navigationBar is going to be translucent and you can't change that. The only properties that you can change are the ones supported by the Appearance Proxy. From Apple Documentation:
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.
That leaves you with limited options to change your MFMailComposeViewController's Navigation Bar Appearance, as not all properties are supported (e.g. if you try something like [UINavigationBar appearance] setTranslucent:NO]; it'll crash, because this property is not supported by the proxy.
Here's a list of properties supported by the Appearance proxy: https://gist.github.com/mattt/5135521
Now, to set the MFMailComposeViewController's navigationBar to be non-translucent, you need to change its backgroundColor (It's an UIView allowed property, UINavigationBar is a subclass of UIView):
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
Make sure you do this before you instantiate your MFMailComposeViewController, for example:
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
You can also use appearanceWhenContainedIn:MFMailComposeViewController, to affect the navBar only when it's being owned by a MFMailComposeViewController, or you can optionally change it back to whatever it was before in mailComposeController:didFinishWithResult.
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