在iOS 7上更改MFMailComposerViewController中的导航按钮颜色 [英] Change navigation button color in MFMailComposerViewController on iOS 7

查看:1045
本文介绍了在iOS 7上更改MFMailComposerViewController中的导航按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to change the text color for navigation buttons in a MFMailComposerViewController but it doesn't work like on iOS 6. In iOS 6 it worked with UIAppearance like this:

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

但这在iOS 7上不起作用,看起来总是这样:

But this doesn't work on iOS 7 and looks always like this:

我也尝试设置<导航栏上的code> tintColor 属性,但这也没有效果:

I also tried to set the tintColor attribute on the navigationBar but this has no effect either:

navigationBar.tintColor = [UIColor redColor];

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

Is there anyway to change the navigation button text color in a MFMailComposeViewController on iOS 7?

推荐答案

我用过这个并在iOS7 +中完美运作

I used this and works perfect in 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]; 

这篇关于在iOS 7上更改MFMailComposerViewController中的导航按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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