Latest 0.1.0
Homepage https://github.com/lichenglu/SideBarMenuController
License MIT
Platforms ios 8.0, requires ARC
Authors

[![CI Status](http://img.shields.io/travis/Chenglu Li/SideBarMenuController.svg?style=flat)](https://travis-ci.org/Chenglu Li/SideBarMenuController)
Version
License
Platform

Installation

SideBarMenuController is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SideBarMenuController"

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Then simply import the framework:

import SideBarMenuController

Now you have a subclass of UIViewController called SideBarMenuController. To implement the class, you can either make your target viewController a subclass of SideBarMenuController, like this:

class ViewController: SideBarMenuController {
    // Get your storyboard reference. We will need it to put your (main and left)viewControllers 
    // into the SideBarMenuController
    let storyBoard = UIStoryboard(name: "Main", bundle: nil)

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // Initialize the viewController with the required designated init method
    required init?(coder aDecoder: NSCoder) {

        let leftViewController = storyBoard.instantiateViewControllerWithIdentifier("Red")
        let mainViewController = storyBoard.instantiateViewControllerWithIdentifier("Green")

        super.init(leftViewController: leftViewController, mainViewController: mainViewController, overlap: 100)
    }
}

Or you could simply create an instance of SideBarMenuController and attach to your current viewController:

class ViewController: UIViewController{
  let sideBarMenuController: SideBarMenuController!

  override func viewDidLoad(){
    super.viewDidLoad()
    sideBarMenuController = SideBarMenuController(init method here)
  }
}

Demo GIF

By default, you could toggle menu with swipe gesture. To toggle menu with other actions like touch(button tapped), you will need delegate between your parent scroll view and other views. Then simply trigger this internal function in your delegate method to toggle the menu:

self.toggleLeftMenuAnimated(true)

Internal Methods You May Want to Explore:

// Close the leftViewController
closeMenuAnimated(animated: Bool)

// Open the leftViewController
openLeftMenuAnimated(animated: Bool)

// Open the leftViewController if it is closed, vice versa, close it if it is open 
toggleLeftMenuAnimated(animated: Bool)

Author

Chenglu Li, [email protected]

License

SideBarMenuController is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SideBarMenuController",
    "version": "0.1.0",
    "summary": "A subclass of UIScrollViewController.",
    "description": "A framework to help get started with a sideBar menu",
    "homepage": "https://github.com/lichenglu/SideBarMenuController",
    "license": "MIT",
    "authors": {
        "Chenglu Li": "[email protected]"
    },
    "source": {
        "git": "https://github.com/lichenglu/SideBarMenuController.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "SideBarMenuController": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This