I have created a custom transition animation for a modal view controller by implementing the methods in the UIViewControllerTransitioningDelegate protocol.
If anyone comes across this in later years, and you're using Swift 3, make sure that your call isn't to "animationControllerForPresentedController".
As of Xcode 8.1, the compiler doesn't automatically recognize this problem and thus doesn't offer to convert the code to modern syntax.
The above code will compile but it won't be a protocol implementation. It will just be a custom, uncalled function. (Such are the hazards of optional protocol methods, and the myriad problems with Xcode's autocomplete.)
So, make sure you implement the protocol with Swift 3 syntax:
func animationController(forPresented presented: UIViewController,
presenting: UIViewController,
source: UIViewController)
-> UIViewControllerAnimatedTransitioning?
{
// ... return your cached controller object here.
}
And remember to set the presentation style on the View Controller to be presented:
self.modalPresentationStyle = .custom
And the delegate:
self.transitioningDelegate = self // or wherever