Tay*_*ith 5 ios swift 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", 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)
Run Code Online (Sandbox Code Playgroud)
这就是屏幕上的样子。选项是暗淡的(我相信后视图会受到其影响)。
我能够添加此代码以使其成为纯白色,但是分离的好处消失了。
let subview = optionMenu.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.whiteColor()
alertContentView.layer.cornerRadius = 2
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:不变暗,但不太正确
关于如何不让背景影响UIAlertController中的选项的任何想法?
我将此UIAlertController添加到具有白色背景的页面中,看起来应该是这样。
谢谢!
这不是一个错误。没有什么是“暗淡的”。警报按钮是半透明的,因此它们在深色背景上颜色更深。它们在红色背景上呈微红色,在蓝色背景上呈蓝色;这就是半透明的意思。所有应用程序中的所有操作表都是这样的。这里没有问题。别担心,开心就好。
| 归档时间: |
|
| 查看次数: |
761 次 |
| 最近记录: |