gpt4 book ai didi

ios - 为什么我的 UIAlertController 中的选项变暗,我该如何解决?

转载 作者:搜寻专家 更新时间:2023-10-31 21:48:14 24 4
gpt4 key购买 nike

这很奇怪。我正在使用以下代码制作一个 UIAlertController:

let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: UIAlertControllerStyle.ActionSheet)

let action = UIAlertAction(title: "Action 1", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})

let action2 = UIAlertAction(title: "Action 2", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})

let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})

optionMenu.addAction(cancelAction)
optionMenu.addAction(action)
optionMenu.addAction(action2)

self.presentViewController(optionMenu, animated: true, completion: nil)

这是它在屏幕上的样子。选项很暗淡(我相信拉入或受到后 View 的影响)。

Dimmed Options

我能够添加此代码以使其成为纯白色,但分离的好处消失了。

let subview = optionMenu.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.whiteColor()
alertContentView.layer.cornerRadius = 2

它看起来像这样:Non-dimmed, but not quite right

关于如何不让背景影响 UIAlertController 中的选项有什么想法吗?

我将此 UIAlertController 添加到具有白色背景的页面,它看起来应该如此。

谢谢!

最佳答案

这不是错误。没有什么是“暗淡的”。警报按钮是半透明的,因此它们在深色背景上显得更暗。它们在红色背景上也呈红色,在蓝色背景上呈蓝色;这就是半透明的意思。所有应用程序中的所有操作表都是这样的。这里没有问题。别担心,要开心。

关于ios - 为什么我的 UIAlertController 中的选项变暗,我该如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33264349/

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