[英]How to use the UInavigationcontroller animation with library Motion?
I came across a library call Motion on GitHub which provide sets of transition on view and controllers. 我在GitHub上遇到了一个库调用Motion,该库提供了视图和控制器上的过渡集。 Based on the website, to use the animation on navigation controller we need to create a new navigation controller class like below, and I apply the new navigation controller.
基于网站,要在导航控制器上使用动画,我们需要创建一个新的导航控制器类,如下所示,我将应用新的导航控制器。 But when it failed and not pushing to the new view controller.
但是当它失败并且没有推送到新的视图控制器时。
the GitHub link is https://github.com/CosmicMind/Motion GitHub链接是https://github.com/CosmicMind/Motion
class AppNavigationController: UINavigationController {
open override func viewDidLoad() {
super.viewDidLoad()
isMotionEnabled = true
motionNavigationTransitionType = .zoom
}
}
then on the main view: 然后在主视图上:
let navigation = AppNavigationController()
navigation.pushViewController(newViewController, animated: false)
If you're using Motion
's animated NavigationController
throughout your app, you can set it this way in your AppDelegate
's didFinishLaunchingWithOptions
method. 如果您在整个应用中都使用
Motion
的动画NavigationController
,则可以在AppDelegate
的didFinishLaunchingWithOptions
方法中以这种方式进行设置。
let newViewController = NewViewController(nibName: "NewViewController",bundle: nil)
let navigation = AppNavigationController(rootViewController: newViewController!)
self.window?.rootViewController = navigation
self.window?.makeKeyAndVisible()
UPDATE: If you want to create a separate NavigationController
and push specific UIViewController
to it, then you need to present the navigation controller instead of pushing it. 更新:如果要创建一个单独的
NavigationController
并将特定的UIViewController
推入该UIViewController
,则需要提供导航控制器而不是将其推入。 See below. 见下文。
let motionNavController = AppNavigationController(rootViewController: galleryViewController)
motionNavController.motionNavigationTransitionType = .none
motionNavController.isNavigationBarHidden = true
self.present(motionNavController, animated: true, completion: nil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.