Search code examples
iosswiftmaterial-designcosmicmind

Using NavigationDrawerController with ToolbarController in the same UIViewController


In CosmicMind / Material library, they are showing how to use one module at a time like:

window = UIWindow(frame: Device.bounds)
window!.rootViewController = AppToolbarController(rootViewController: RootViewController())
window!.makeKeyAndVisible()

what if I want to add another module to the same rootViewController like:

ToolbarController with NavigationDrawerController ?

I'm new to iOS and Swift, I would be thankful for your help.


Solution

  • So the idea behind the navigation controllers, like NavigationDrawerController and ToolbarController is that you can stack them. So if you want the ToolbarController to be in the root area of the NavigationDrawerController, you only need to do this:

    NavigationDrawerController(rootViewController: AppToolbarController(rootViewController: RootViewController))
    

    You can continue this pattern with any controller that has a rootViewController initializer.