Skip to content
Grigorii Lutkov edited this page Apr 19, 2021 · 2 revisions

With UINavigationController

As Container for UINavigationController

If you want for a side menu be available through the entire app, then the recommended way is to make UINavigationController the root view controller for LGSideMenuController:

let navigationController = UINavigationController(rootViewController: UIViewController())
let sideMenuController = LGSideMenuController(rootViewController: navigationController)

This way, when you open side view, the whole UINavigationController, including its UINavigationBar will be hidden.

Inside UINavigationController

If you want for a side menu be available only on one screen, then it makes sense to push LGSideMenuController as one of UINavigationController's child view controllers:

let sideMenuController = LGSideMenuController(rootViewController: UIViewController())
let navigationController = UINavigationController(rootViewController: sideMenuController)

This way, when you open side view, only root view of UINavigationController will be changed, which means UINavigationBar will stay on the same place.

With UITabBarController

Logic is the same as with UINavigationController.

As Container for UITabBarController

If you want for a side menu be available through the entire app, then the recommended way is to make UITabBarController the root view controller for LGSideMenuController:

let tabBarController = UITabBarController()
tabBarController.setViewControllers([UIViewController(), UIViewController()], animated: false])
let sideMenuController = LGSideMenuController(rootViewController: tabBarController)

This way, when you open side view, the whole UITabBarController, including its UITabBar will be hidden. And for each tab side view will be the same view.

Inside UITabBarController

If you want for a side menu be available only on one tab, or you want to have different side views for each tab, then it makes sense to set LGSideMenuController as one of UITabBarController's child view controllers:

let sideMenuController1 = LGSideMenuController(rootViewController: UIViewController())
let sideMenuController2 = LGSideMenuController(rootViewController: UIViewController())
let tabBarController = UITabBarController()
tabBarController.setViewControllers([sideMenuController1, sideMenuController2], animated: false])

This way, when you open side view, only opened tab of UITabBarController will be changed, which means UITabBar will stay on the same place. And for each tab side view will be a different view.