Handle cancel of swipe animation better

This commit is contained in:
Jackson Harper
2023-09-13 20:00:18 +08:00
parent c12cf4d5bc
commit 250f78c3f3

View File

@ -45,12 +45,14 @@ extension SlideAnimatedTransitioning: UIViewControllerAnimatedTransitioning {
fromVC.view?.layer.shadowOpacity = 0.1
}, completion: { _ in
toVC.view?.layer.opacity = 1.0
toVC.view?.layer.shadowOpacity = 0
fromVC.view?.layer.opacity = 1.0
fromVC.view?.layer.shadowOpacity = 0
if !transitionContext.transitionWasCancelled {
toVC.view?.layer.opacity = 1.0
toVC.view?.layer.shadowOpacity = 0
fromVC.view?.layer.opacity = 1.0
fromVC.view?.layer.shadowOpacity = 0
fromVC.view.removeFromSuperview()
fromVC.view.removeFromSuperview()
}
// when cancelling or completing the animation, ios simulator seems to sometimes flash black backgrounds during the animation. on devices, this doesn't seem to happen though.
// containerView.backgroundColor = [UIColor whiteColor];
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)