Custom UIViewController Transition using UIStoryboardSegue
The most popular way is to use UIViewControllerAnimatedTransitioning.
To do this, you must do the following:
- Create a subclass, which can be called âXXXTransitioningâ, inheriting from âNSObjectâ and implementing the two functions in the âUIViewControllerAnimatedTransitioningâ protocol.
1 | func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval |
- Then:
- Create an instance of âXXXTransitioningâ in the âViewController â.
- Set
transitioningDelegate = self. - Extend âViewControllerâ with
UIViewControllerTransitioningDelegateand implement:
1 | func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? |
dismiss
I noticed that the Storyboard Segue has a Custom option.

1 | class XXXModalSegue: UIStoryboardSegue { |
Thatâs it, no need for coding delegate and Extension. Simple and clean :)
Translated by gpt-3.5-turbo