如何从默认的蓝色为MFMailComposeViewController生成UIBarButtonItems的颜色? [英] How do I make the color of UIBarButtonItems for MFMailComposeViewController from the default blue?

查看:149
本文介绍了如何从默认的蓝色为MFMailComposeViewController生成UIBarButtonItems的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我似乎尝试什么,在用户选择通过电子邮件发送链接时出现的电子邮件屏幕(它是 MFMailComposeViewController ),按钮始终是默认设置蓝色。

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.

我的AppDelegate中有这个:

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] }];

它确实为 MFMailComposeViewController的标题着色但不是按钮。我如何实现这一目标?

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];
}];

从iOS 6开始,MFMailComposeViewController(以及其他一些视图控制器)在一个单独的进程上运行,因此他们不会继承您的应用程序中使用的样式。假设您使用的是最新的SDK,使用上述方法可能会有所帮助,至少可以在iOS 7上运行。 您可以在此处阅读有关远程视图控制器的更多信息。

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.

这篇关于如何从默认的蓝色为MFMailComposeViewController生成UIBarButtonItems的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆