I am Using Swift 3. I have searched about this and found the solution
navigationDrawerController?.TransitionFromRootViewController
but when I used this line it say TransitionFromRootViewController
is not a function.
So I tried Using
navigationDrawerController?.transition(from: RootViewController(), to: destViewController(), duration: 0.2, options: .transitionCrossDissolve, animations: nil, completion: nil)
but it shows error that the:
"child view controller must have a common parent view controller when calling transitionfrom view controller"
Can anyone help me please? If someone can push an example of navigation drawer with the switching would be a great.
Here is the solution, which I posted to the NavigationDrawerController example project in the programmatic directory, Material 2.1.2.
It shows how to transition with multiple navigation controllers, and by itself.
import UIKit
import Material
class LeftViewController: UIViewController {
private var transitionButton: FlatButton!
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.blue.base
prepareTransitionButton()
}
@objc
internal func handleTransitionButton() {
// Transition the entire NavigationDrawer rootViewController.
// navigationDrawerController?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
// Transition the ToolbarController rootViewController that is in the
// NavigationDrawer rootViewController.
(navigationDrawerController?.rootViewController as? ToolbarController)?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
}
internal func closeNavigationDrawer(result: Bool) {
navigationDrawerController?.closeLeftView()
}
private func prepareTransitionButton() {
transitionButton = FlatButton(title: "Transition VC", titleColor: Color.white)
transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(transitionButton).horizontally().center()
}
}
You can find a reference to the discussion in GitHub issue-546
All the best!