Latest 0.6.0
License MIT
Platforms ios 8.0
Dependencies SnapKit
Frameworks UIKit


An iOS drawer controller in swift


  • Xcode 10.2+
  • Swift 5.0+
  • iOS Deployment Target 8.0+



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate ZKDrawerController into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '8.0'

target 'YourApp' do
    pod 'ZKDrawerController'

Then, run the following command:

$ pod install


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate ZKPageViewController into your Xcode project using Carthage, specify it in your Cartfile:

github "superk589/ZKDrawerController"

Run carthage update to build the framework and drag the built ZKDrawerController.framework into your Xcode project.


If you prefer not to use either of the aforementioned dependency managers, you can integrate ZKDrawerController into your project manually.



let centerController = UIViewController()
let leftController = UIViewController()
let rightController = UIViewController()

let drawerController = ZKDrawerController(center: centerController, right: rightController)
let drawerController = ZKDrawerController(center: centerController, left: leftController)
let drawerController = ZKDrawerController(center: centerController, right: rightController, left: leftController)

// have none of the two sides, and then add dynamically
let drawerController = ZKDrawerController(center: centerController)
drawerController.rightViewController = UIViewController()

set drawer style

// side controller covers the main controller, shadows the edge of side controllers' view
drawerController.drawerStyle = .cover

// side controller inserts below the main controller, shadows the edge of main controller's view
drawerController.drawerStyle = .insert

// side controller lays beside the main controller
drawerController.drawerStyle = .plain

show or hide side controller manually, animated: true), animated: true)
drawerController.hide(animated: true)

set main controller’s scale

// scale should be 0 to 1
drawerController.mainScale = 0.8

set background color or image

// set background color
drawerController.containerView.backgroundColor = UIColor.white

// set background image
drawerController.backgroundImageView.image = image

set center controller’s view foreground color while side view is showing

// this view will change it's alpha while side view is showing from 0 to 1
drawerController.mainCoverView.backgroundColor =

set left and right side width

drawerController.defaultRightWidth = 300
drawerController.defaultLeftWidth = 300

set shadow width

drawerController.shadowWidth = 5

set gesture recognizer width in main controller

drawerController.gestureRecognizerWidth = 40

should require failure of navigation pop gesture, default true (if setting false, showing left drawer gesture will have higher priority)

drawerController.shouldRequireFailureOfNavigationPopGesture = true

setup gestures priority, higher priority gestures will proc before drawer controller’s gesture and lower priority gestures will proc after failure of drawer controller’s gesture

drawerController.higherPriorityGestures = [gesture1, gesture2]
drawerController.lowerPriorityGestures = [gesture3, gesture4]

set the side or main controller dynamically

// set or replace
drawerController.centerViewController = newViewController
drawerController.rightViewController = newViewController
drawerController.leftViewController = newViewController
// remove the side view controller, mainVC can not be removed
drawerController.rightViewController = nil
drawerController.leftViewController = nil

use ZKDrawerController as your root controller and show various main controller-based side controllers.

// in AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let home = ViewController()
    let nav = UINavigationController(rootViewController: home)
    let drawer = ZKDrawerController(center: nav, right: nil, left: nil)
    // do some setup
    drawer.mainScale = 0.8
    drawer.drawerStyle = .cover
    // ...
    window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = drawer
    home.drawerController = drawer
    return true

// in ViewController.swift
var drawerController: ZKDrawerController!
override func viewDidAppear(_ animated: Bool) {
    let vc = UIViewController()
    drawerController.rightViewController = vc
override func viewWillDisappear(_ animated: Bool) {
    drawerController.rightViewController = nil   

Latest podspec

    "name": "ZKDrawerController",
    "version": "0.6.0",
    "summary": "An iOS drawer controller in swift.",
    "description": "A light-weighted iOS drawer controller in swift.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "zhenkai zhao": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "0.6.0"
    "source_files": "Sources/*.swift",
    "frameworks": "UIKit",
    "dependencies": {
        "SnapKit": []
    "swift_versions": "5.0"

Pin It on Pinterest

Share This