Custom UIViewController Transition

--

I will show with an example:

Presenting and Presented View Controllers

I have two UIViewControllers, one is to present and the other one is to be presented. They both have UITapGestureRecognizer on their views. When tapped, the presenting one presesents and the presented one dismisses. And the transition is not custom yet.

To make it custom, first we need an animator class which conforms to UIViewControllerAnimatedTransitioning protocol. In this class, we set the duration and the animation of the transition:

Transitioning Animator

Now that we have our transitioning animator ready, we need to make the presenting view controller conform to UIViewControllerTransitioningDelegate and return the animator in its delegate methods. Also while presenting, we need to set transitioningDelegate and modalPresentationStyle:

Final Presenting View Controller

And the final transition:

--

--

No responses yet