问题描述
这个问题适用于运行iOS 7的Xcode 5,非常奇怪。我试图将所有UInavigation和UIBarButtonItem文本颜色设置为白色。
This question is for Xcode 5 running iOS 7 and is super weird. I am trying to set all the UInavigation and UIBarButtonItem text colors to white.
所以在我的app启动委托中,我将代码设置为。
So in my app launch delegate I set the code as.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImage *NavigationPortraitBackground = [UIImage imageNamed:@"button_header_blue"];
// Set the background image all UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];
// Set the text appearance for navbar
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor whiteColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Helvetica Neue" size:21], UITextAttributeFont,
nil]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],
UITextAttributeTextColor,
[UIColor whiteColor],
UITextAttributeTextShadowColor,
nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
// Override point for customization after application launch.
return YES;
}
如果我两次启动发送邮件操作
- 第一次我看到UIBarButton项目是白色的。我看着它并点击取消按钮
- 第二次我看到它们全部变灰并且除标题外几乎看不见。
- 这是在我的iPhone模拟器和运行iOS 7的iPhone上发生的。
If I launch "send mail" action twice- first time I see UIBarButton items white. I look at it and hit the Cancel button- second time I see them all of them grayed out and barely visible except for the title.- This is happening in both my iPhone simulator and iPhone running iOS 7.
我该如何解决这个问题?
how can I fix this?
推荐答案
我必须这样做为了让它在iOS 7上运行的方式
I had to do it this way in order for it to work on iOS 7
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController.navigationBar setTintColor:[UIColor whiteColor]];
[mailViewController.navigationBar setBarTintColor:[UIColor whiteColor]];
....
这篇关于MFMailComposeViewController外观setTintColor迷失iOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!