[英]Swift ViewController Background getting black with alpha
I'm calling a ViewController as popover when the user presses a button. 当用户按下按钮时,我正在调用ViewController作为弹出窗口。 The View should have black background with alpha 0.5.
视图应具有alpha 0.5的黑色背景。 But the View is shown as that for a second, than the whole background turns black without alpha.
但是视图显示为一秒钟,而不是整个背景变为黑色而没有alpha。 Any idea why?
知道为什么吗?
Thats my popover call: 这是我的popover电话:
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .popover
self.present(popOver, animated: true, completion: nil)
I'm trying to set the background color in popovers viewDidLoad()
function with following code: 我正在尝试使用以下代码在popovers
viewDidLoad()
函数中设置背景颜色:
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
For that set modalPresentationStyle
to overCurrentContext
instead of popover
. 对于集
modalPresentationStyle
到overCurrentContext
代替popover
。
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .overCurrentContext
self.present(popOver, animated: true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.