问题
I'm using a UIVisualEffectView to blur a section of the screen in SpriteKit like so:
let blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
let UIEffectView:UIVisualEffectView = UIVisualEffectView(effect: blur)
UIEffectView.frame = CGRectMake(0, 0, frame.width, frame.height * 0.15)
self.view?.addSubview(UIEffectView)
But it appears as a grey shaded area instead of a blur. Strangely, it blurs whilst the GameCenter notification shows at the start, saying "Welcome back, (player)" - but once the notification disappears, it goes back to being a grey box.
Same applies to when you go into the multi-task view in iOS9, the preview has the section blurred, but when you go into the app, it reverts to being a grey shaded area again.
Any ideas why this is happening? It does the same in the simulators as well as physical hardware.
回答1:
I had the same headache before use UIVisualEffectView to create a blur view, correct on simulator but not on iphone & ipad, it turns out weird stuff can happen when you mess UIKit
together with SpriteKit
. I would suggest use SKEffectNode
to do the blur job, instead of UIVisualEffectView
.
来源:https://stackoverflow.com/questions/34363872/uivisualeffectview-creates-a-grey-box-instead-of-blurring