squarehippo10 squarehippo10 - 1 year ago 107
iOS Question

Add UIView over blurred UIView

I am trying to create a popup menu over a blurred background. I created the function below to blur the view which works great, but when I try to add the menu, it gets blurred as well. I suppose I could take a snapshot of my view and put that under my popup, but I'm guessing there's a better way...

func blurView() {
let blurEffect = UIBlurEffect(style: .Light)
let effectView = UIVisualEffectView(effect: blurEffect)
effectView.frame = view.frame
effectView.alpha = 0

UIView.animateWithDuration(2.0) { effectView.alpha = 0.8 }

Answer Source

If you are just unhiding a previously added menu view to show the menu, then the blurView (which was just added) is probably in front of your menu view as well as everything else. After you add the blurView, when you want to show the menu, try something like:

menuView.hidden = false

That should move the menu in front of the effect view so it doesn't get blurred.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download