Ios 为什么我的UIAlertController中的选项变暗?我如何修复它?

Ios 为什么我的UIAlertController中的选项变暗?我如何修复它?,ios,swift,uialertcontroller,Ios,Swift,Uialertcontroller,这是一个奇怪的。我正在使用以下代码制作UIAlertController: let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: UIAlertControllerStyle.ActionSheet) let action = UIAlertAction(title: "Action 1", style: .Default, handler: {

这是一个奇怪的。我正在使用以下代码制作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)
下面是它在屏幕上的样子。选项很模糊(我相信拉入或受到后视图的影响)

我能够添加这个代码,使其成为纯白色,但分离的美妙消失了

let subview = optionMenu.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.whiteColor()
alertContentView.layer.cornerRadius = 2    
看起来是这样的:

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

我把这个UIAlertController添加到一个白色背景的页面上,看起来应该是这样的


谢谢

这不是一个bug。没有什么是“暗淡的”。警报按钮是半透明的,因此在黑暗背景下它们会更暗。它们在红色背景上呈红色,在蓝色背景上呈蓝色;这就是半透明的含义。所有应用程序中的所有操作表如下所示。这里没有问题。别担心,开心点。

这是我的目标c代码。请尝试swift的对应项:

[alert.view setBackgroundColor:[UIColor whiteColor]];

希望有帮助

您可以选择暗显的行吗?您是否使用UIAppearance anywhere对任何元素的外观进行了任何全局更改?Hi@shim我可以选择行。我相信下面的马特是对的,但我仍然想知道如何使它们不半透明,并保持其原始形状;作为补充说明,您只需使用optionMenu.view.backgroundColor=UIColor.whiteColor()即可获得第二张图像,无需在视图中四处搜索。它仍然覆盖默认的形状,我仍然不确定如何保留它们并使用不透明的白色。即使有些人喜欢这种外观,也有很多人希望所有按钮都是相同的颜色/透明度。取消全白色和所有其他有点灰色的动作不是我的设计所要求的…@Tasonir然后不要使用UIAlertController。它不会做任何你自己做不到的事情。如果你只使用一个定制的视图控制器,你可以做任何你想做的事情。