I'm trying to make a custom CATransition such that pushing a viewController looks exactly the same as presenting one modally.
so far I have this for present
override func viewWillAppear(_ animated:Bool){
super.viewWillAppear(animated)
self.transition = CATransition()
self.transition.duration = 0.4
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.transition.type = kCATransitionMoveIn
self.transition.subtype = kCATransitionFromTop
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.navigationController?.view.layer.add(self.transition, forKey: nil)
}
And this for dismiss
override func viewWillDisappear(_ animated:Bool){
super.viewWillDisappear(animated)
self.transition.type = kCATransitionReveal
self.transition.subtype = kCATransitionFromBottom
self.navigationController?.view.layer.removeAllAnimations()
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.navigationController?.view.layer.add(self.transition, forKey: nil)
}
And this is how I push it from a navigationController
self.navigationController?.pushViewController(myViewController(), animated: false)
What I have is not extremely different from the default UIViewController.present(vc, animated: true, completion: nil) animation, but it's subtly different, especially the easing and the dismiss animation.
Does anyone know what exact values I can use to most closely replicate the animation I'm looking for?