, когда я перевожу * Third3Controller * на SecondViewController *, подпредставление (viewToGoUp) контроллера второго представления должно go подняться, и должно появиться подпредставление (comeUpView) контроллера третьего представления. Я попробовал следующий способ. С кодом ниже, viewToGoUp
class CustomNavAnimator:NSObject,UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as? SecondViewController else {
//reverseAnimation(using: transitionContext)
return
}
guard let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as? ThirdViewController else {
return
}
transitionContext.containerView.addSubview(toVC.view)
transitionContext.containerView.addSubview(fromVC.view)
fromVC.viewToGoUp.alpha = 1.0
toVC.comeUpView.center = CGPoint(x: toVC.comeUpView.center.x, y: toVC.comeUpView.center.y+500)
UIView.animate(withDuration: self.transitionDuration(using: transitionContext), animations: {
fromVC.viewToGoUp.alpha = 0.0
fromVC.viewToGoUp.center = CGPoint(x: fromVC.viewToGoUp.center.x, y: fromVC.viewToGoUp.center.y - 500)
toVC.comeUpView.center = CGPoint(x: toVC.comeUpView.center.x, y: toVC.comeUpView.center.y-500)
}) { (done) in
transitionContext.completeTransition(done)
}
}
}