【问题标题】:iOS 7: Tint color randomly changes after showing a popupiOS 7:显示弹出窗口后色调颜色随机变化
【发布时间】:2014-08-03 01:15:42
【问题描述】:

我遇到了一个非常奇怪的问题,让我发疯。

问题是有时(并不总是发生),在显示一个弹出窗口后,条形按钮和任何 UISegmentedControl 会变成红色,而它们应该是白色的(见下图)。

这也是我设置应用程序色调颜色的代码(在应用程序委托初始化方法中):

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIColor redColor], NSForegroundColorAttributeName,
                                                       shadow,NSShadowAttributeName,
                                                       [UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
                                                       NSFontAttributeName,
                                                       nil]];

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor redColor], NSForegroundColorAttributeName,
                                                      shadow,NSShadowAttributeName,
                                                      [UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
                                                      NSFontAttributeName,
                                                      nil] forState:UIControlStateNormal];

if ([self.window respondsToSelector:@selector(setTintColor:)])
    self.window.tintColor = [UIColor redColor];

[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];

[[UITabBar appearance] setTintColor:[UIColor redColor]];

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];

知道为什么会这样吗?我认为如果我的代码有问题,导航栏按钮和分段控件会在应用程序启动后变为红色,而不是在一段时间后。大家觉得呢?

谢谢

【问题讨论】:

    标签: ios7 uinavigationbar uibarbuttonitem uisegmentedcontrol tintcolor


    【解决方案1】:

    介意将背景颜色设置为白色吗?这似乎是改变了。如果这可以纠正它,那么我们就有了一个起点

     [[UITabBar appearance] setBackgroundColor:[UIColor whiteColor];
    

    尝试并回复。

    【讨论】:

    • 您好 Plasher,谢谢您的回答。我会试一试。顺便说一句,我不明白为什么这会在显示弹出窗口后的一段时间内发生,而不是在应用程序开始运行后发生。有人知道吗?
    【解决方案2】:

    注释以下两行后问题就消失了:

    if ([self.window respondsToSelector:@selector(setTintColor:)])
    self.window.tintColor = [UIColor redColor];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      • 2014-11-14
      • 1970-01-01
      • 2014-10-19
      • 1970-01-01
      相关资源
      最近更新 更多