blurred background in swift with clear subview

Viewed 5417

i want a blurred background. i have a subview for the main view . and i want the subview to not be affected by blur. What should i do?

Code:

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
        let blurEffectView = UIVisualEffectView(effect: blurEffect)

        blurEffectView.frame = view.bounds


 let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
   let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
        vibrancyEffectView.frame = view.bounds

       view.addSubview(blurEffectView)

        view.addSubview(vibrancyEffectView)


        FrameView = UIView()


        if let FrameView = FrameView {

            FrameView.layer.borderColor = UIColor.white.cgColor
            FrameView.layer.borderWidth = 2
 FrameView.frame=CGRect(x:30,y:(view.frame.height/2-50),width:view.frame.width-60,height:100)
            blurEffectView.contentView.addSubview(FrameView)


   }

So i want the view to be blurred and the FrameView to be clear.

This is what my app currently looks like.

2 Answers
Related