gpt4 book ai didi

uiviewcontroller - iOS7 tint color 仅在呈现和关闭另一个 ViewController 后才有效

转载 作者:行者123 更新时间:2023-12-01 01:03:19 26 4
gpt4 key购买 nike

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

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

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

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

这是我设置着色的方式:

首先,我在界面生成器中的每个 View Controller 上设置了色调颜色,这些设置在工作和有问题的 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];

有任何想法吗?

最佳答案

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

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

self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

关于uiviewcontroller - iOS7 tint color 仅在呈现和关闭另一个 ViewController 后才有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21071512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com