4

我在 iOS7 中遇到了一个非常奇怪的色调问题。

当我第一次加载时遇到问题的 ViewController 时,所有的色调都是浅灰色,好像一切都处于非活动状态或位于使屏幕变暗的 UIAlertView 后面。这些按钮仍然处于活动状态并且工作正常,但它们都是灰色的。(我将色调设置为橙色,稍后会详细介绍)。

这是奇怪的部分。如果我呈现,然后立即关闭另一个 ViewController,所有的橙色色调都会出现,并且一切都按预期工作。这是我能够使色调出现的唯一方法 - 似乎没有其他方法起作用。

我在整个应用程序中使用相同的基本代码模式,而这个问题实际上只影响一个 ViewController。呈现了这个特定的 ViewController UIModalPresentationFullScreen,并且UIModalTransitionStyleCoverVertical,如果这些很重要的话。

这是我设置着色的方式:

首先,我在界面生成器中的每个视图控制器上设置了色调颜色,这些设置在工作和有问题的 VC 中都是相同的。

接下来,我在我的 App Delegate 中全局设置了一个色调,如下所示:

    [_window setTintColor:[UIColor orangeColor]];

以上两个适用于我的大多数 ViewController,但由于某种原因并非全部适用。对于那些它不起作用的,我一直在使用一些不同的技术来使色调颜色起作用。例如:

self.view.tintColor = [UIColor orangeColor];

或者

[_myUIBarButtonItem setTitleTextAttributes:
 [NSDictionary dictionaryWithObject:[UIColor orangeColor]
                             forKey:NSForegroundColorAttributeName]
                                           forState:UIControlStateNormal];

或强制 tintColor 更新:

[_myButtonOutlet setTitleColor:_cancelButtonOutlet.tintColor
                      forState:UIControlStateNormal];

有任何想法吗?

4

1 回答 1

4

在 iOS7 中,您可以根据需要选择不同的色调行为。

您需要做的就是在应用委托中的 didFinishLaunching 中将窗口的 tintAdjustmentMode 属性调整为 Normal。

self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
于 2014-05-19T20:53:40.673 回答