Search code examples
iosswiftpresentviewcontroller

Present ViewController: Page Sheet animation, but faster


I'd like to make use of the new fancy Page Sheet presenting animation in iOS 13, but I'd like to speed it up a bit. Is there a way to lower the duration without implementing a complete custom duration?

I have tried using CATransition, which does not change anything about the animation.

let transition: CATransition = CATransition()
transition.duration = 0.05
self.view.window!.layer.add(transition, forKey: nil)
self.present(presentedVc, animated: true, completion: nil)

Solution

  • You can control all animations speed by setting the speed on the window:

     window?.layer.speed = 1.5 // or 0.1 to slow motion // `1` is default
    

    this means 1.5 times faster than usual.

    If you set it on the main window of the application, all animations will be affected (like turning on Slow Animations option of the simulator)