I'm trying to make a UIView with a UIVisualEffectView subview with a UIBlurEffect as the effect. The view is created off the side of the screen and then is slid in using an animation.
Everything works just fine on the simulator (I've tested on an iPhone 4S and an iPhone 6) however on my phone (iPhone 6) the blur just isn't blurring, it looks more like a dark grey with an alpha of 0.5. In addition, when I take a screenshot of the device or open it up from the home screen, the blur is rendered for that single frame before consistent rendering starts again.
Here's a screenshot of the view as it is at the moment:
However on the device the blur isn't there, it's essentially just a dark, transparent view.
Here's the code I use to initialise the view, the blurView and vibrancyView properties are declared as global variables:
init(left: Bool){
self.left = left
let screenSize = UIScreen.mainScreen().bounds.size
var rect: CGRect
if left{
rect = CGRectMake(-screenSize.width*0.3, 0, screenSize.width*0.3, screenSize.height)
}else{
rect = CGRectMake(screenSize.width, 0, screenSize.width*0.3, screenSize.height)
}
super.init(frame: rect)
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame = CGRectMake(0, 0, self.frame.width, self.frame.height)
self.addSubview(blurView)
let vibrancy = UIVibrancyEffect(forBlurEffect: blurEffect)
vibrancyView = UIVisualEffectView(effect: vibrancy)
vibrancyView.frame = blurView.frame
blurView.addSubview(vibrancyView)
self.userInteractionEnabled = true
}
And to move the superView, that contains the blurView, in:
func moveIn(){
UIView.animateWithDuration(0.3, animations: { () -> Void in
var center = self.center
if self.left{
center.x = UIScreen.mainScreen().bounds.size.width*0.15
}else{
center.x = UIScreen.mainScreen().bounds.size.width*0.85
}
self.center = center
})
}
As I said before the animation and such works fine but the blurView doesn't blur.
I'm not sure what's going on with this, it makes me think it's something to do with rendering frames but I'm no guru so if anyone has any ideas I'd be more than grateful.
Aucun commentaire:
Enregistrer un commentaire