在iOS 7上更改MFMailComposerViewController中的导航按钮颜色

Oem*_*erA 19 uiappearance ios7 mfmailcomposeviewcontroller

我正在尝试更改MFMailComposerViewController中导航按钮的文本颜色,但它在iOS 6上不起作用.在iOS 6中,它与UIAppearance一起工作如下:

// Navigation button
UIBarButtonItem *barButton = [UIBarButtonItem appearance];
NSDictionary *barButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor redColor]};
NSDictionary *disabledBarButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor grayColor]};

[barButton setTitleTextAttributes:barButtonTitleTextAttributes forState:UIControlStateNormal];
[barButton setTitleTextAttributes:disabledBarButtonTitleTextAttributes forState:UIControlStateDisabled];
[barButton setBackgroundImage:[[UIImage imageNamed:@"btn_appearance"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

但这在iOS 7上不起作用,看起来总是这样: 在此输入图像描述

我也尝试tintColor在navigationBar上设置属性,但这也没有效果:

navigationBar.tintColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)

无论如何在iOS 7上更改MFMailComposeViewController中的导航按钮文本颜色?

Jav*_*aña 35

我使用它并且在iOS7 +中完美运行

MFMailComposeViewController* mailViewController = [[MFMailComposeViewController alloc] init];        
mailViewController.mailComposeDelegate = self;
[mailViewController setToRecipients:@[@"email@apple.com"]];

[mailViewController.navigationBar setTintColor:[UIColor orangeColor]];

[self presentViewController:mailViewController animated:YES completion:nil]; 
Run Code Online (Sandbox Code Playgroud)


dli*_*sin 3

如果您在UIWindow上设置tintColor ,它在第一次呈现 MFMailComposerViewController 时工作得很好。看起来它丢失了后续调用的tintColor信息。

注意:这会改变窗口每个元素的色调。