gpt4 book ai didi

swift - UIAlertController 不会把后台的所有元素都转成B/W

转载 作者:搜寻专家 更新时间:2023-11-01 05:54:52 24 4
gpt4 key购买 nike

编辑:包含我的解决方案的存储库:UIAlertControllerDimmed


显示 UIAlertController 后,大部分背景变暗并变成黑色和白色。一些元素变暗,但不会变成黑白。

这些元素是(在屏幕截图中从上到下):

  • UINavigationItem 中的 UIImageView
  • 具有红色背景颜色和白色图像的 UIButton
  • UITabBarItem 中的 UIImageView

with alert controller

我找不到与此主题相关的任何内容。我还必须更改什么才能使这些项目变暗?

这是没有 UIAlertController 的:

without alert controller ]

最佳答案

我认为这里发生的事情是您正在设置某些元素的 tintColor 并且您对 tintColor 的行为与对 的行为不同backgroundColortextColor(或图像中的颜色)。

When an alert or action sheet appears, iOS 7 automatically dims the tint color of the views behind it. To respond to this color change, a custom view subclass that uses tintColor in its rendering should override tintColorDidChange to refresh the rendering when appropriate.

例如,我创建了一个显示警报 Controller 的简单应用。我将左键色调颜色设置为清除颜色,将文本颜色设置为蓝色:

enter image description here

我将右键颜色设置为系统绿色:

enter image description here

当我运行应用程序并显示警报 Controller 时,它看起来像这样

之前:

enter image description here

之后:

enter image description here

为了获得您正在寻找的行为,您需要遵循@Alexander 的回答中的建议。您需要在屏幕上创建四个图像的灰度版本,并为它们制作动画过渡。

关于swift - UIAlertController 不会把后台的所有元素都转成B/W,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52932418/

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