Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make the color of UIBarButtonItems for MFMailComposeViewController from the default blue?

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.

like image 898
Doug Smith Avatar asked Dec 05 '22 08:12

Doug Smith


1 Answers

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.

like image 182
Terry Avatar answered Feb 14 '23 21:02

Terry