如何优化segue中动画的hidesBackButton代码?

How optimize hidesBackButton code for animation in segue?

我正在以编程方式将 DynamicVC 转换为 SearchVC

@objc func goToSearchVC() {

        let searcVC = SearchVC()

        //Hide system navigation controller back button
        searcVC.navigationItem.hidesBackButton = true
        searcVC.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "closeBtn_20"), style: .plain, target: self, action: #selector(closeBtnTapped))
        searcVC.navigationItem.title = ""

        navigationController?.pushViewController(searcVC, animated: true)
        searcVC.view.backgroundColor = .lightGray
    }

hidesBackButton执行很慢,"Back"按钮在segue动画中闪烁:

我该如何解决这个问题?是否可以对此进行优化?谢谢。

我使用以下代码解决了闪烁 "Back" 按钮的问题:

let transition:CATransition = CATransition()
    transition.duration = 0.5
    transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    transition.type = kCATransitionPush
    transition.subtype =  kCATransitionFromRight
    self.navigationController!.view.layer.addAnimation(transition, forKey: kCATransition)
    self.navigationController?.pushViewController(searchVC, animated: false)

使用的另一种过渡类型:

kCATransitionFromLeft

kCATransitionFromBottom

kCATransitionFromRight

kCATransitionFromTop