4

No matter what I seem to try, in the email screen that comes up when a user chooses to email a link (it's a MFMailComposeViewController) the buttons are always the default blue.

I have this in my AppDelegate:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.000 green:156/255.0 blue:51/255.0 alpha:1]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName: [UIColor whiteColor] }];

And it does indeed color the title of the MFMailComposeViewController but not the buttons. How do I accomplish that?

It also keeps my status bar black when I have it white everywhere else.

Doug Smith
  • 29,668
  • 57
  • 204
  • 388
  • possible duplicate of [Change navigation button color in MFMailComposerViewController on iOS 7](http://stackoverflow.com/questions/19333855/change-navigation-button-color-in-mfmailcomposerviewcontroller-on-ios-7) – dlinsin Jan 06 '14 at 13:09

2 Answers2

16
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setToRecipients: [NSArray arrayWithObjects:@"recipients", nil]];
[mailController setSubject: @"Contact Us"];
[mailController setMessageBody: @"Mail Body" isHTML:NO];
[[mailController navigationBar] setTintColor: [UIColor blackColor]]; //color
[self presentViewController: mailController animated:YES completion:^{
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
}];

Since iOS 6, MFMailComposeViewController (and some other view controllers) are run on a separate process, as such they will not inherit the style used in your app. Using the above method may help, it does, at least work on iOS 7, assuming you're using the most up-to-date SDK. You can read more about remote view controllers here.

Terry
  • 616
  • 6
  • 16
  • Hmm, any idea why the status bar stays black still? Your solution worked beautifully for the UIBarButtonItems. – Doug Smith Nov 02 '13 at 00:06
0

You can set a global tint color for your UIBarButtonItems in AppDelegate so that the MFMailComposeViewController will use it as color for its own buttons.

    let barButtonItemAppearance = UIBarButtonItem.appearance()
    barButtonItemAppearance.tintColor = KK.GRAPHICS.COLOR_WHITE
Il Pisanello
  • 117
  • 2
  • 4