Q:

How do I handle orientation changes in the presenting UIViewController when using a custom transition

I have a UIViewController as the root view controller that presents another UIViewController using a custom transition. When you rotate the device while looking at the child view controller, then go back to the root view controller, the root view controller's view frame isn't updated. I've narrowed it down to the presence of a custom transition, i.e. if you don't have a custom transition, it works just fine. What would be the best way to have the custom transition and have the root view controller handle orientation changes appropriately? 
I have a demo project available here: https://github.com/rawbee/TestOrientation

A:

Seems that you just forgotten to set the frame for the view controller that is being presented:
toVC.view.frame = fromVC.view.frame

Just add this line to animateTransition so that the method looks like this:
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    guard let fromVC = transitionContext.viewController(forKey: .from),
        let toVC = transitionContext.viewController(forKey: .to),
        let snapshot = fromVC.view.snapshotView(afterScreenUpdates: false)
        else { return }

    let containerView = transitionContext.containerView

    // you want the newly presented view to have the same frame as the old one
    toVC.view.frame = fromVC.view.frame

    containerView.addSubview(toVC.view)
    containerView.addSubview(snapshot)

    let animator = UIViewPropertyAnimator(duration: transitionDuration(using: transitionContext), curve: .easeInOut) {
        snapshot.alpha = 0.0
    }
    animator.addCompletion { _ in
        snapshot.removeFromSuperview()
        transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
    }
    animator.startAnimation()
}

