简体   繁体   English

如何将UInavigationcontroller动画与库Motion一起使用?

[英]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 ,则可以在AppDelegatedidFinishLaunchingWithOptions方法中以这种方式进行设置。

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.

相关问题 如何将我的UINavigationBar转换为UINavigationController(供此库使用)? - How can I turn my UINavigationBar into UINavigationController (for use with this library)? 我们可以在UITabBarController上使用UINavigationController动画吗 - Can we use the UINavigationController animation on UITabBarController 如何在UINavigationController中使用UIImagePickerController - How to use a UIImagePickerController with UINavigationController 如何在 SwiftUI 中使用 UINavigationController - how to use UINavigationController in SwiftUI 如何将 UIDocumentPickerViewController 与 UINavigationController 一起使用? - How to use UIDocumentPickerViewController with UINavigationController? 如何在UINavigationController中使用UIViewControllerAnimatedTransitioning? - How to use UIViewControllerAnimatedTransitioning with UINavigationController? 如何使用uinavigationcontroller - How to use uinavigationcontroller 如何正确使用UINavigationController - How to properly use a UINavigationController UINavigationController-如何更改单个UIViewController的动画 - UINavigationController - how to change animation for single UIViewController 如何将状态栏与UINavigationController的动画一起移动 - How to Move status bar along with the animation of UINavigationController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM