Deeyennay Deeyennay - 1 year ago 136
Swift Question

How to get UIVisualEffectView to blur without going OVER full screen / current context?

I have a SpriteKit game where I want to blur only a part of the screen (the board where the game is played). But at the same time, I want to be able to interact with the other elements (like UIButtons) on the screen. So basically I'm looking for something like a form sheet, but one that blurs what is under it and allows interaction with the main view controller.

So here's my problem. I've tried to:

  1. put the
    on my main view controller,

  2. present another view controller modally with one of the standard presentation styles and have the
    in there, or

  3. present another view controller modally OVER full screen / current context and have the
    in there.

None of these options work for me.

  • Options 1 and 2 don't actually blur. They produce a solid black box instead. (Although for some reason it blurs when I get a notification or when I pull down Notification Center or pull up Control Center. So I'm facing the same problem as this user.)

  • Option 3 does blur, but does not allow for interaction with the main view controller.

Does anyone know what else I could try? Or am I not using something correctly?

Answer Source

Unfortunately UIVisualEffectView simply doesn't work well with SpriteKit, even when using SKView. I've tried everything from A to zPositions.

I decided to recreate my UIButtons in the new view controller and present it modally OFS. That way I have access to the beautiful UIVisualEffectView blurring (SKEffectNode blurring isn't pretty at all IMO) and to my buttons. I hope Apple will work on the synergy of their frameworks in future versions of iOS and Swift. Then again, I'm not exactly an expert when it comes to app development, so if there is anything else I could've done I'd love to hear it :-)

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