Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIVisualEffectView delay with UIModalTransitionStyle CrossDissolve

I'm presenting a modal view controller that has a background with a UIVisualEffectView with an UIBlurEffect of type .light

I'm presenting the modal view controller as below:

infoViewController.modalPresentationStyle = .overFullScreen
infoViewController.modalTransitionStyle = .crossDissolve
self.present(infoViewController, animated: true, completion: nil)

I'm noticing that the blur effect view does not appear until the crossDissolve animation has completed. This is not the case for other transition styles such as coverVertical.

This is happening only on iOS 10 with Swift 3.

How can I get the crossDissolve animation to work along with the visual effect view on my infoViewController. Any suggestions/workarounds?

like image 907
mohonish Avatar asked Oct 17 '16 12:10

mohonish


2 Answers

What I do is replacing the crossDisolve with a CATransition, like this:

self.present(controller,
             animated: false,
             completion: nil)

let transition = CATransition()
transition.duration = 0.3
transition.type = kCATransitionFade
view.window?.layer.add(transition, forKey: nil)

Hope it helps.

like image 181
manueGE Avatar answered Oct 13 '22 10:10

manueGE


Check your consule, you should see there the reason -

<_UIPopoverBackgroundVisualEffectView 0x7fe053562840> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.

You can't use the UIVisualEffectView with crossDissolve animation...

like image 20
Yedidya Reiss Avatar answered Oct 13 '22 10:10

Yedidya Reiss