首页 > 解决方案 > 推送 UIViewController

问题描述

有没有办法通过自定义屏幕显示来推送视图控制器?,就像呈现一个视图控制器,modalPresentationStyle = .custom!当推送带有自定义动画的视图控制器时,推送的视图控制器会消失。

标签: iosswiftuinavigationcontroller

解决方案


您可以通过在过渡时分配所需的动画来推送:

let yourVC = self.storyboard?.instantiateViewController(withIdentifier: "YOURVIEWCONTROLLER") as! YOURVIEWCONTROLLER
    UIView.animate(withDuration: 0.6, animations: {() -> Void in
    UIView.setAnimationCurve(.easeInOut)
    self.navigationController?.pushViewController(yourVC, animated: true)
    UIView.setAnimationTransition(.flipFromRight, for: (self.navigationController?.view)!, cache: false)
})

推荐阅读