I have created a custom transition animation for a modal view controller by implementing the methods in the UIViewControllerTransitioningDelegate protocol.
Another issue is that transitioningDelegate is a weak property. So you can assign to it, then have your transitioning delegate class be released before the transition has a chance to run. When the transition does run, the value of transitioningDelegate is nil, and your methods never get called.
To see this, do the following:
let myVC = UIViewController(nibName: nil, bundle: nil)
likesVC.transitioningDelegate = BackgroundFadesInPresentationDelegate(viewController: likesVC)
likesVC.modalPresentationStyle = .custom
present(likesVC, animated: true, completion: nil)
Then in your transition delegate class, add
deinit {
print("deinit")
}
And see if that print statement is hit before the transition.
You will run into this problem if you use a freestanding class to implement the UIViewControllerTransitioningDelegate. This is why tutorials such as this one generally have you implement the transitioning delegate in the either in the view controller class itself or as an extension. Other things are keeping the view controller from getting released.
In general in Cocoa Touch anything named "...Delegate" will be a weak property, to help avoid retain cycles. You should make your own custom class delegate properties weak as well. There's a good section on this in Apple's Cocoa Core Competencies.