【问题标题】:MFMailComposeViewController appearance setTintColor getting lost iOS 7MFMailComposeViewController 外观 setTintColor 迷路 iOS 7
【发布时间】:2013-12-25 03:20:58
【问题描述】:

这个问题是针对运行 iOS 7 的 Xcode 5 的,非常奇怪。我正在尝试将所有 UInavigation 和 UIBarButtonItem 文本颜色设置为白色。

所以在我的应用启动委托中,我将代码设置为。

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

我该如何解决这个问题?

【问题讨论】:

  • 根据 Apple 开发人员支持:这是 iOS 7.0 中的一个已知错误。

标签: ios iphone objective-c xcode


【解决方案1】:

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

if ([MFMailComposeViewController canSendMail])
    {

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

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

....

【讨论】:

  • 你把这个放在哪里了?我遇到了同样的问题,但是我使用的是 UIActivityViewController。这还能用吗?
  • 此特定代码用于导航栏和邮件控制器。您可以在上面看到我使用的所有代码。我认为它不会在 UIActivityViewController 中工作,除非您在其中使用 uinavigation 栏
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多