rv7284
5/3/2017 - 4:55 AM

SlideMenuControllerSwift

SlideMenuControllerSwift

extension UIViewController {
    
    func setNavigationBarItem() {
        self.addLeftBarButtonWithImage(#imageLiteral(resourceName: "ic_menu_white"))
        self.slideMenuController()?.removeLeftGestures()
        self.slideMenuController()?.addLeftGestures()
    }
    
    func removeNavigationBarItem() {
        self.navigationItem.leftBarButtonItem = nil
        self.slideMenuController()?.removeLeftGestures()
    }
}
storyboard = UIStoryboard(name: "Main", bundle: nil)
let menuVC = storyboard.instantiateViewController(withIdentifier: "Menu") as! Menu
let homeVC = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let navC = UINavigationController(rootViewController: homeVC)
        
slideMenuController = SlideMenuController(mainViewController: navC, leftMenuViewController: menuVC)
self.window?.rootViewController = slideMenuController
self.window?.makeKeyAndVisible()