UIVisualEffectView创建一个灰色框而不是模糊 [英] UIVisualEffectView creates a grey box instead of blurring

查看:137
本文介绍了UIVisualEffectView创建一个灰色框而不是模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIVisualEffectView来模糊SpriteKit中的屏幕区域,如下所示:

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)

但是它显示为灰色阴影区域而不是模糊区域.奇怪的是,它模糊了,而GameCenter通知却在开始时显示,说欢迎回来,(玩家)",但是一旦通知消失,它就会变成一个灰色框.

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.

同样适用于在iOS9中进入多任务视图时,预览区域模糊,但是在进入应用程序时,它又恢复为灰色阴影区域.

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.

推荐答案

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.

这篇关于UIVisualEffectView创建一个灰色框而不是模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆