UIVisualEffectView creates a grey box instead of blurring

匆匆过客 提交于 2019-12-23 19:41:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!