Swift自定义转换不工作(未调用UIViewControllerTransitioningDelegate)

Swift自定义转换不工作(未调用UIViewControllerTransitioningDelegate),swift,animation,transition,transitions,uiviewanimationtransition,Swift,Animation,Transition,Transitions,Uiviewanimationtransition,我只是想切换到第二个视图控制器。我的HomeViewController具有以下扩展: extension HomeViewController: UIViewControllerTransitioningDelegate { func animationController(forPresented presented: UIViewController, presenting: UIViewController,

我只是想切换到第二个视图控制器。我的HomeViewController具有以下扩展:

extension HomeViewController: UIViewControllerTransitioningDelegate {
    func animationController(forPresented presented: UIViewController,
                             presenting: UIViewController,
                             source: UIViewController)
        -> UIViewControllerAnimatedTransitioning? {
        return transition
    }

    public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return nil
    }
}
和类中定义的转换

let transition = PopAnimator()
我有一个按钮,当它被点击时,应该切换视图控制器并使用自定义转换(PopAnimator):

PopAnimator类(目前实际上只是一个fadeIn):

单击该按钮时,它将切换ViewController,但不使用自定义转换。如果我在animationController(forPresented:presenting:source:)函数或PopAnimator类中放置断点,则不会到达该断点

        self.present(viewController, animated: false, completion: nil)
如果要设置动画过渡,请尝试设置
animated:true

class PopAnimator: NSObject, UIViewControllerAnimatedTransitioning {
    let duration = 1.0
    var presenting = true
    var originFrame = CGRect.zero

    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return duration
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        let containerView = transitionContext.containerView

        let toView = transitionContext.view(forKey: .to)!

        containerView.addSubview(toView)
        toView.alpha = 0.0
        UIView.animate(withDuration: duration,
        animations: {
            toView.alpha = 1.0
        },
        completion: { _ in
            transitionContext.completeTransition(true)
        }
        )
    }
}
        self.present(viewController, animated: false, completion: nil)