SSDrawerViewController
MSDynamicDrawerViewController is written in Objective-C. So, I convert it and write in Swift.
Install / Use
/learn @Urtaq/SSDrawerViewControllerREADME
SSDrawerViewController
What is this for?
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.
Requirements
- iOS 8.1+
- Swift 3.0+
Installation
Manual Import
Just drag these sources into your project.
I'll support Cocoapods or Carthage ASAP.
Usage
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
class AppDelegate: UIResponder, UIApplicationDelegate, SSDrawerViewControllerDelegate {
...
var window: UIWindow?
var drawerController: SSDrawerViewController?
var isDrawable: Bool = true
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
...
// DrawerViewController
self.drawerController = self.window!.rootViewController as? SSDrawerViewController
self.drawerController?.delegate = self
self.drawerController?.addStylerFromArray([SSDrawerScaleStyler.styler(), SSDrawerFadeStyler.styler(), SSDrawerShadowStyler.styler()], forDirection: SSDrawerDirection.Left)
let menuViewController: 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 {
if let menuViewController = drawerViewController.drawerViewController as? SSMenuViewController {
if let 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 {
return self.isDrawable
}
}
// SSMenuViewController.swift
class SSMenuViewController: UIViewController {
...
weak var drawerViewController: SSDrawerViewController?
...
func transitionToViewController() -> Void {
let animateTransition: Bool = self.drawerViewController?.mainViewController != nil
let mainNavigationController: UINavigationController = (UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MasterNavigationController") as? UINavigationController)!
self.drawerViewController?.setMainViewController(mainNavigationController, animated: animateTransition, completion: nil)
}
}
License
SSDrawerViewController is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
