I have a custom transition between viewcontrollers that fades the current VC out and the new one in which works great, but on iOS 13 now when the viewcontroller is presented modally with its new transition where you can still see the previous VC in the background, my transition is overriding it, I would like it to keep the gap at the top and the rounded corners instead of becoming fullscreen.
Example of it working the old way (ive slowed the animations down):
how it looks on iOS 13:
this is the code im using to do the transition:
class FadeAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 3
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from),
let toVC = transitionContext.viewController(forKey: .to)
else {
return
}
let duration = self.transitionDuration(using: transitionContext)
transitionContext.containerView.backgroundColor = .white
transitionContext.containerView.addSubview(toVC.view)
transitionContext.containerView.addSubview(fromVC.view)
toVC.view.alpha = 0
UIView.animate(withDuration: duration, animations: {
toVC.view.alpha = 1
fromVC.view.alpha = 0
}, completion: { _ in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
})
}
}
the snapshot
and the toVC
are the ones becomes the full size of the screen instead of remaining the same size and shape of the fromVC
. How can I prevent this from happening?