squarehippo10 squarehippo10 - 3 months ago 8x
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 }


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.