MFMailComposeViewController外观setTintColor迷失iOS 7

时间:2013-12-25 03:20:59

标签: ios iphone objective-c xcode

这个问题适用于运行iOS 7的Xcode 5,并且非常奇怪。我试图将所有UInavigation和UIBarButtonItem文本颜色设置为白色。

因此,在我的app启动委托中,我将代码设置为。

- (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上。

我该如何解决这个问题?

enter image description here enter image description here

1 个答案:

答案 0 :(得分:11)

我必须这样做才能在iOS 7上运行

if ([MFMailComposeViewController canSendMail])
    {

        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
        mailViewController.mailComposeDelegate = self;

        [mailViewController.navigationBar setTintColor:[UIColor whiteColor]];
        [mailViewController.navigationBar setBarTintColor:[UIColor whiteColor]];

....