我以编程方式从DynamicVC
到SearchVC
制作segue:
@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
执行速度非常慢,"返回"按钮在segue动画中闪烁:
我该如何解决这个问题?有可能优化这个吗?感谢。
答案 0 :(得分:0)
我使用以下代码闪烁“后退”按钮解决了问题:
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