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

前端之家收集整理的这篇文章主要介绍了ios – 为什么我的UIAlertController中的选项变暗,我该如何解决?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这很奇怪.我正在使用以下代码制作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",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)

这就是它在屏幕上的样子.选项很暗(我相信拉入或受到后视图的影响).

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相关文章