无论我似乎尝试什么,当用户选择通过电子邮件发送链接(这是一个MFMailComposeViewController
)时出现的电子邮件屏幕中,按钮始终是默认的蓝色。
我在我的应用程序代表中有这个:
[[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
的标题着色,但不是按钮。我该如何做到这一点?
当我在其他任何地方都保持白色时,它还使我的状态栏保持黑色。
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(和其他一些视图控制器)在单独的进程上运行,因此它们不会继承应用中使用的样式。 使用上述方法可能会有所帮助,至少在iOS 7上确实有效,假设您使用的是最新的SDK。您可以在此处阅读有关远程视图控制器的更多信息。
您可以在 AppDelegate 中为 UIBarButtonItems 设置全局色调颜色,以便 MFMailComposeViewController 将其用作其自己的按钮的颜色。
let barButtonItemAppearance = UIBarButtonItem.appearance()
barButtonItemAppearance.tintColor = KK.GRAPHICS.COLOR_WHITE