本文介绍了iOS7色调仅在呈现和解除另一个ViewController后才起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS7中的色彩颜色有一个非常奇怪的问题。

I'm having a very odd problem with tint color in iOS7.

当我第一次加载时出现问题的ViewController时,所有的色调都是浅灰色,好像一切都处于非活动状态,或者在UIAlertView后面,它使屏幕变暗。按钮仍处于活动状态,工作正常,但它们都是灰色的。 (我将色调设置为橙色,稍微多了一点)。

When the ViewController that I'm having trouble with first loads, all of the tint is a light gray color, as if everything is inactive or behind a UIAlertView that has dimmed the screen. The buttons are still active and work just fine, but they are all gray. (I have the tint color set to orange, more on that in a bit).

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

Here's the odd part. If I present, and then immediately dismiss another ViewController, all of the orange tint appears and everything works as expected. That is the only way I have been able to get the tint to appear - nothing else seems to work.

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

I'm using the same basic code patterns throughout the app, and this problem really only affects one ViewController. This particular ViewController is presented UIModalPresentationFullScreen, and UIModalTransitionStyleCoverVertical, if those matter at all.

以下是我设置着色的方法:

Here's how I'm setting tinting:

首先,我在界面构建器中的每个视图控制器上设置了一种色调颜色,这些设置是工作和有问题的风险投资相同。

First, I have set a tint color on each view controller within interface builder, these settings are the same across both working and problematic VCs.

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

Next, I have set a tint color globally in my App Delegate like this:

    [_window setTintColor:[UIColor orangeColor]];

以上两个适用于我的大多数ViewControllers,但由于某些原因不适用于所有这些。对于那些没有工作的,我一直在使用一些不同的技术来使色调颜色起作用。例如:

The above two work on most of my ViewControllers, but not on all of them for some reason. For the ones that it was not working on, I've been using a handful of different techniques to get the tint color to work. For example:

self.view.tintColor = [UIColor orangeColor];

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

或强制进行tintColor更新:

or to force a tintColor update:

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

任何想法?

推荐答案

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

In iOS7, there are different tint behaviors you can choose from depending on what you want.

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

All you need to do is adjust the window's tintAdjustmentMode property to Normal in didFinishLaunching in app delegate.

self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

这篇关于iOS7色调仅在呈现和解除另一个ViewController后才起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 22:18