Search code examples
iosswiftuiimageviewuiblureffect

How do I make my UIImageView be on top of the Blur Effect in Swift?


I have this camera app im working on and once the picture is taken the view gets blurred including the captured image. I would like the captured image to be on top of the blur effect so It doesnt get blurred and the user could be able to see the picture they took. How would I be able to do that? This is the code I have currently:

if !UIAccessibilityIsReduceTransparencyEnabled() {
    self.view.backgroundColor = UIColor.clearColor()

                let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
                let blurEffectView = UIVisualEffectView(effect: blurEffect)
                blurEffectView.frame = self.view.bounds
                blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]

                self.view.addSubview(blurEffectView) 



                    } 
                    else {
                        self.view.backgroundColor = UIColor.blackColor()
                    }

Solution

  • Any views added to the effect views content view will not be blurred. Any views behind the effect view will be blurred.