Вопрос

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.

Это было полезно?

Решение

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.

Другие советы

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top