推动UIViewController

问题描述 投票:0回答:2

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

ios swift uinavigationcontroller
2个回答
0
投票

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

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)
})

0
投票

是的,您可以制作自定义动画来推送视图控制器。

您可以实现自己的UINavigationControllerDelegate,在其中可以触发自己的过渡动画。有很多网站解释如何做到这一点。您可以检查herehere,还有很多UIViewControllerAnimatedTransitioning的示例。只要寻找一些不错的教程,如何实现。

© www.soinside.com 2019 - 2024. All rights reserved.