UIVisualEffectView not setting to nil

322 views Asked by At

I have a UIVisualEffectView that I am trying to set to nil upon viewdidload

What am I doing wrong?

@IBOutlet var popUpView: UIView!

@IBOutlet weak var visualEffectView: UIVisualEffectView!

var effect: UIVisualEffect!

@IBOutlet weak var headerLabel: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()

    effect = visualEffectView.effect
    self.visualEffectView.effect = nil
    popUpView.layer.cornerRadius = 5

}
1

There are 1 answers

0
Jitendra Modi On
    See my answer


    var blurEffect = UIBlurEffect()
    var blurview : UIView = UIView()

    //HERE pass view as bringtofront from blurview and pass view where you want to set blurview upon
        func add_blur_view(v : UIView, view_bring_to_front: UIView) {
            blurEffect  = UIBlurEffect(style: UIBlurEffectStyle.dark)
            let blurEffectView = UIVisualEffectView(effect: blurEffect)
            blurEffectView.frame = v.bounds
            blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            v.addSubview(blurEffectView)
            v.bringSubview(toFront: view_bring_to_front)
        }

        func remove_blur_view(v : UIView)  {
            for subview in v.subviews {
                if subview is UIVisualEffectView {
                    subview.removeFromSuperview()
                }
            }
        }