11

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?

mohonish
  • 1,396
  • 1
  • 9
  • 21

2 Answers2

5

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.

manueGE
  • 1,169
  • 11
  • 14
1

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...

Yedidya Reiss
  • 5,316
  • 2
  • 17
  • 19