MSDynamicDrawerViewController is written in Objective-C.
So, I convert it and write in Swift.
This is integrated with UIKit Dynamics APIs(new in iOS7).
For a detail, you can refer the MSDynamicDrawerViewController.
- iOS 8.1+
- Swift 3.0+
Just drag these sources into your project.
I'll support Cocoapods or Carthage ASAP.
The usage of SSDrawerViewController is same with MSDynamicDrawerViewController.
But, compared to MSDynamicDrawerViewController, SSDrawerViewController is written in Swift.
As a result, the usage is slightly different depends on each language's syntax.
So, I'd like to share my use case in Swift 3.
// AppDelegate.swift
classAppDelegate:UIResponder,UIApplicationDelegate,SSDrawerViewControllerDelegate{...varwindow:UIWindow?vardrawerController:SSDrawerViewController?varisDrawable:Bool=true...func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?)->Bool{...
// DrawerViewController
self.drawerController =self.window!.rootViewController as?SSDrawerViewControllerself.drawerController?.delegate =selfself.drawerController?.addStylerFromArray([SSDrawerScaleStyler.styler(),SSDrawerFadeStyler.styler(),SSDrawerShadowStyler.styler()], forDirection:SSDrawerDirection.Left)letmenuViewController:SSMenuViewController=(self.window?.rootViewController?.storyboard?.instantiateViewController(withIdentifier:"MenuViewController")as?SSMenuViewController)!
menuViewController.drawerViewController =self.drawerController
self.drawerController?.setDrawerViewController(menuViewController, forDirection:SSDrawerDirection.Left)
// Transition to the first view controller
menuViewController.transitionToViewController()self.window?.rootViewController =self.drawerController
self.window?.makeKeyAndVisible()...}...
// MARK: - SSDrawerViewControllerDelegate
func drawerViewController(_ drawerViewController:SSDrawerViewController, mayUpdateToPaneState paneState:SSDrawerMainState, forDirection direction:SSDrawerDirection){print("Drawer view controller may update to state `\(paneState)` for direction `\(direction)`")if paneState ==.open {iflet menuViewController = drawerViewController.drawerViewController as?SSMenuViewController{iflet headerView = menuViewController.menuTableView.headerView(forSection:0)as?SSMenuHeadView{
headerView.configView()}}}}func drawerViewController(_ drawerViewController:SSDrawerViewController, didUpdateToPaneState paneState:SSDrawerMainState, forDirection direction:SSDrawerDirection){print("Drawer view controller did update to state `\(paneState)` for direction `\(direction)`")}func drawerViewController(_ drawerViewController:SSDrawerViewController, shouldBeginPanePan panGestureRecognizer:UIPanGestureRecognizer)->Bool{returnself.isDrawable
}}// SSMenuViewController.swift
classSSMenuViewController:UIViewController{...
weak vardrawerViewController:SSDrawerViewController?...func transitionToViewController()->Void{letanimateTransition:Bool=self.drawerViewController?.mainViewController !=nilletmainNavigationController:UINavigationController=(UIStoryboard(name:"Main", bundle:nil).instantiateViewController(withIdentifier:"MasterNavigationController")as?UINavigationController)!
self.drawerViewController?.setMainViewController(mainNavigationController, animated: animateTransition, completion:nil)}}SSDrawerViewController is available under the MIT license. See the LICENSE file for more info.