Ios 视图上的模糊背景不一致

Ios 视图上的模糊背景不一致,ios,swift,background,viewcontroller,uiblureffect,Ios,Swift,Background,Viewcontroller,Uiblureffect,使用以下代码使视图的背景模糊的效果并不一致 func makeBackgroundBlurry () { var blurEffect = UIBlurEffect() blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.frame = view.bou

使用以下代码使视图的背景模糊的效果并不一致

func makeBackgroundBlurry () {
    var blurEffect = UIBlurEffect()
    blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = view.bounds //view is self.view in a UIViewController
    view.insertSubview(blurEffectView, atIndex: 0)
    view.backgroundColor = UIColor.clearColor()


    //add auto layout constraints so that the blur fills the screen upon rotating device
    blurEffectView.setTranslatesAutoresizingMaskIntoConstraints(false)
    view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
    view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
    view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Leading, multiplier: 1, constant: 0))
    view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Trailing, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Trailing, multiplier: 1, constant: 0))
}
背景模糊应用于视图控制器,该视图控制器以如下方式显示:

@IBAction func editTitleButtonAction(sender: UIButton) {
        let vc = FieldEditor(nibName: "FieldEditor", bundle: nil)
        vc.labelOne = "Make / Manufacturer"
        vc.valueOne = item.manufacturer
        vc.labelTwo = "Model / Item Name"
        vc.valueTwo = item.name
        vc.delegate = self
        self.presentViewController(vc, animated: true, completion:nil)

    }
偶尔,它会根据需要工作,在背景上创建灯光模糊效果;但是,大多数情况下,背景是模糊的,但呈现当前视图的视图在其下方不可见。事实上,它正在模糊黑色背景。但是,如果视图的显示是动画的,则视图仅在动画过程中显示为正确的模糊背景

我也尝试过这样表达观点,但无济于事:

self.presentViewController(vc, animated: true, completion:{vc.makeBackgroundBlurry()})
如何解决这一问题,使模型显示的视图在显示期间和完成时都有模糊的背景

显示当前视图的视图在下面不可见

这是你应该期待的。当您呈现视图控制器时,默认情况下,呈现视图控制器的视图将消失。显示的视图控制器的视图后面没有任何内容。这是正常的。因此,您可以看到半透明视图控制器视图后面的黑色窗口

但是,在iOS 8中,您可以使用
.OverFullScreen
作为显示视图控制器的模式显示样式,以防止显示视图控制器的视图消失:

 vc.modalPresentationStyle = .OverFullScreen
显示当前视图的视图在下面不可见

这是你应该期待的。当您呈现视图控制器时,默认情况下,呈现视图控制器的视图将消失。显示的视图控制器的视图后面没有任何内容。这是正常的。因此,您可以看到半透明视图控制器视图后面的黑色窗口

但是,在iOS 8中,您可以使用
.OverFullScreen
作为显示视图控制器的模式显示样式,以防止显示视图控制器的视图消失:

 vc.modalPresentationStyle = .OverFullScreen

我知道,使用
SKNode
,有一个名为
zPosition
的属性。值越高,越正面。查看是否有类似的属性,并相应地对其进行分层。我知道使用
SKNode
,有一个名为
zPosition
的属性。值越高,越正面。看看是否有类似的属性,并相应地将其分层。完美!我根据“.OverFullScreen”进行了一些搜索,发现这篇文章很好地涵盖了这个主题。完美的我根据“.OverFullScreen”进行了一些搜索,发现这篇文章很好地涵盖了这个主题。