Latest 2.1.0
Homepage https://github.com/ykyouhei/KYDrawerController
License MIT
Platforms ios 8.0, requires ARC
Authors

Carthage compatible
Pod Version
Pod Platform
Pod License
Language
Swift version

KYDrawerController is a side drawer navigation container view controller similar to Android.

  • Storyboard Support
  • AutoLayout Support

image.png storyboard.pngdrawer.gif

Installation

CocoaPods

KYDrawerController is available on CocoaPods.
Add the following to your Podfile:

pod 'KYDrawerController'

Manually

Just add the Classes folder to your project.

Usage

(see sample Xcode project in /Example)

Code

import UIKit
import KYDrawerController

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        let mainViewController   = MainViewController()
        let drawerViewController = DrawerViewController()
        let drawerController     = KYDrawerController()
        drawerController.mainViewController = UINavigationController(
            rootViewController: mainViewController
        )
        drawerController.drawerViewController = drawerViewController

        /* Customize
        drawerController.drawerDirection = .Right
        drawerController.drawerWidth     = 200
        */

        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = drawerController
        window?.makeKeyAndVisible()

        return true
    }

Storyboard

  1. Set the KYDrawerController to Custom Class of Initial ViewController.

    usage1.png

  2. Connects the KYEmbedDrawerControllerSegue to DrawerViewController from KYDrawerController

    usage2.png

  3. Connects the KYEmbedMainControllerSegue to DrawerViewController from KYDrawerController

    usage3.png

  4. Set the SegueIdentifiers to inspector of KYDrawerController.

    usage4.png

Open/Close Drawer

func setDrawerState(state: DrawerState, animated: Bool)

Delegate

optional func drawerController(_ drawerController: KYDrawerController, willChangeState state: KYDrawerController.DrawerState)
optional func drawerController(_ drawerController: KYDrawerController, didChangeState state: KYDrawerController.DrawerState)

Objective-C version

https://github.com/AustinChou/KYDrawerController-ObjC

License

This code is distributed under the terms and conditions of the MIT license.

Latest podspec

{
    "name": "KYDrawerController",
    "version": "2.1.0",
    "summary": "KYDrawerController is a side drawer navigation container view controller.",
    "homepage": "https://github.com/ykyouhei/KYDrawerController",
    "license": "MIT",
    "authors": {
        "Kyohei Yamaguchi": "[email protected]"
    },
    "social_media_url": "https://twitter.com/kyo__hei",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/ykyouhei/KYDrawerController.git",
        "tag": "2.1.0"
    },
    "source_files": "KYDrawerController/Classes/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This