如何用透明背景创建uiview?

时间:2017-03-04 11:20:00

标签: swift xcode uiview uiviewcontroller

我在patterns.com中看到了这张图片。我尝试创建一个透明背景的模态,但它使uiviewcontroller中的其他内容变得透明。任何想法?

如下图所示

enter image description here

1 个答案:

答案 0 :(得分:1)

模糊效果:Swift 3

    //add blur effect
    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = self.view.bounds
    blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    self.view.addSubview(blurEffectView)

并将其删除:

    blurEffectView.removeFromSuperview()