I am using custom view controller transitions, UIViewControllerAnimatedTransitioning, to present and dismiss a view controller.
The presenting animation
My solution is setting modalPresentationStyle = .custom. It can be before or after the line transitioningDelegate = self.
TLDR:
This discussion regards to presenting transition only, because I didn't have much issue with dismissing transition.
My modal view is smaller than the screen and the presenting view is supposed to be shown in the background. But no, I got a totally black background instead of the presenting view as soon as transitionContext.completeTransition is called. I have a similar modal view with the presenting view in the background somewhere else in code, and it's totally working. After doing some comparison I eliminate all the other possibilities and narrow down to the difference of modalPresentationStyle = .custom, which has .fullScreen for the default value. I guess .fullScreen assumes the presented view takes full screen and decide to remove the presenter view (fromView) regardlessly.
One thing interesting with modalPresentationStyle = .custom: transitionContext.view(forKey: .from) returns nil while transitionContext.viewController(forKey: .from) still returns the presenting view controller.