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

时间:2016-04-21 22:33:55

标签: ios xcode swift interface-builder uivisualeffectview

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 UIVisualEffectView on my main view controller,
  2. present another view controller modally with one of the standard presentation styles and have the UIVisualEffectView in there, or
  3. present another view controller modally OVER full screen / current context and have the UIVisualEffectView 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?

1 个答案:

答案 0 :(得分:1)

不幸的是,即使使用UIVisualEffectViewSKView也无法与SpriteKit很好地协作。我尝试了从A到zPositions的所有内容。

我决定在新的视图控制器中重新创建我的UIButton并以模态方式呈现OFS。通过这种方式,我可以访问美丽的UIVisualEffectView模糊(SKEffectNode模糊,并非在所有IMO中都很漂亮)和我的按钮。我希望Apple能够在未来版本的iOS和Swift中实现其框架的协同作用。再说一次,在应用程序开发方面,我并不是一个专家,所以如果还有其他任何我可以做的事情,我很乐意听到它: - )