UIVisualEffectView does not blur its SKView view

I am writing a SpriteKit game and ran into a blurry view issue that resides on SKView. It should slide to the right when the game is paused, and it should blur the contents of its parent view (SKView) just like the control center panel in iOS 7. Here is the desired appearance:

enter image description here

I really get:

enter image description here

In fact, the left view is not completely black; you can see how the glare from the supervisor fights slightly with the almost opaque subzone, but no blurring is applied. Is this an iOS 8 bug / feature, or is this my mistake / misunderstanding.

Here are my subclass entities of UIVisualEffectView:

class OptionsView: UIVisualEffectView {
//...
    init(size: CGSize) {
        buttons = [UIButton]()
        super.init(effect: UIBlurEffect(style: .Dark))
        frame = CGRectMake(-size.width, 0, size.width, size.height)
        addButtons()
        clipsToBounds = true
    }
    func show() {
        UIView.animateWithDuration(0.3, animations: {
            self.frame.origin.x = 0
        })
    }
    func hide() {
        UIView.animateWithDuration(0.3, animations: {
            self.frame.origin.x = -self.frame.size.width
        })
    }

Then in the GameScene class:

in the initializer:

optionsView = OptionsView(size: CGSizeMake(130, size.height))

in didMoveToView (view: SKView):

view.addSubview(optionsView)

when pause button is pressed:

self.optionsView.show()

P.S. , , , iOS8

  • → UIImageView OptionsView clipToBounds = true → UIImageView ,

  • UIView, UIVisualEffectView UIBlurView SKEffectNode SKCropNode.

+4
2

, , SKEffectNode UIVisualEffectView. -,

class BlurCropNode: SKCropNode {
    var blurNode: BlurNode
    var size: CGSize
    init(size: CGSize) {
        self.size = size
        blurNode = BlurNode(radius: 10)
        super.init()
        addChild(blurNode)
        let mask = SKSpriteNode (color: UIColor.blackColor(), size: size)
        mask.anchorPoint = CGPoint.zeroPoint
        maskNode = mask
    }
}

class BlurNode: SKEffectNode {
    var sprite: SKSpriteNode
    var texture: SKTexture {
        get { return sprite.texture }
        set {
            sprite.texture = newValue
            let scale = UIScreen.mainScreen().scale
            let textureSize = newValue.size()
            sprite.size = CGSizeMake(textureSize.width/scale, textureSize.height/scale)
        }
    }
    init(radius: CGFloat) {
        sprite = SKSpriteNode()
        super.init()
        sprite.anchorPoint = CGPointMake(0, 0)
        addChild(sprite)
        filter = CIFilter(name: "CIGaussianBlur", withInputParameters: ["inputRadius": radius])
        shouldEnableEffects = true
        shouldRasterize = true
    }
}

:

enter image description here

,

  • SKEffectNode , shouldRasterize true. . , .

  • BlurCropNode . - sprite effectNode. dispatch_async .

, -

+2

, , , , , . : http://www.youtube.com/watch?v=eYHId0zgkdE, , . , , . .

-, SKSpriteNode . didMoveToView() . ( blur.fsh GitHub, youtube.)

override func didMoveToView(view: SKView) {
    blurNode.shader = SKShader(fileNamed: "blur")

    self.addChild(blurNode)
}

, , SKTexture, , blurNode.

override func update(currentTime: CFTimeInterval) {
    // Hide the blurNode to avoid it be captured too.
    blurNode.hidden = true
    blurNode.texture = self.view!.textureFromNode(self, crop: blurNode.frame)
    blurNode.hidden = false
}

. iPad mini, 1/3 , fps 58-59. fps 22, , , , .

+1

All Articles