Skip to content
Right and/or left menu that can be swiped to view from the center view, written in Swift šŸ”¶
Swift Objective-C Shell Ruby
Branch: master
Clone or download
Latest commit 41bdee9 Jun 29, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
Pod remove print May 14, 2016
images
.gitignore update gitignore Mar 24, 2016
.travis.yml add testing and codecov to travis Jun 9, 2016
CHANGELOG.md version 1.7.3 May 14, 2016
DualSlideMenu.podspec version 1.7.3 May 14, 2016
LICENSE Initial commit Mar 23, 2016
Package.swift add 2nd gif Apr 9, 2016
README.md Fix README.md Jun 28, 2017
codecov.yml Update codecov.yml Jun 9, 2016

README.md

DualSlideMenu

Version Build Status codecov

Left and right slide menu to keep your main view clutter free

Table of Contents

Why use this

  • Declutters your main view by add more real estate to your app
  • Adds simple animations to improve UX
  • Lots of documentation for methods and function to improve usability
  • Easy for customization
  • Your app can look like Slack's, Facebook's and many of Google's apps

Demo

Video Walkthrough

Tutorial

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

Requirements

Installation

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

pod "DualSlideMenu"
Create a main view controller, which can be considered the home view of the app, and two other view controllers which will be the left and the right side menus. Then add an identifier for the three view controllers which will be used in the AppDelegate.

identifier

In your AppDelegate file, add the pod to the file.
import DualSlideMenu
Then, initialize and add the three view controllers to the container class using the identifers from above
var window: UIWindow?
var storyboard: UIStoryboard?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  window = UIWindow(frame: UIScreen.mainScreen().bounds)
    storyboard = UIStoryboard(name: "Main", bundle: nil)


    let leftView = storyboard?.instantiateViewControllerWithIdentifier("LeftMenuController")
    let rightView = storyboard?.instantiateViewControllerWithIdentifier("RightMenuController")
    let mainView = storyboard?.instantiateViewControllerWithIdentifier("MainController")

    let controller = DualSlideMenuViewController(mainViewController: mainView!, leftMenuViewController: leftView!, rightMenuViewController: rightView!)
    window!.rootViewController = controller
    window!.makeKeyAndVisible()
    return true
}
If you only want to use a certain side for a menu then initialize using the following method
let leftView = storyboard?.instantiateViewControllerWithIdentifier("LeftMenuController")
let mainView = storyboard?.instantiateViewControllerWithIdentifier("MainController")

let controller = DualSlideMenuViewController(mainViewController: mainView!, leftMenuViewController: leftView!)
The width of display for the side menus can be changed by adding this line of code to your AppDelegate inside of the didFinishLaunchWithOptions method. The offset must be added for both left and right side menu
controller.leftSideOffset = 200
controller.rightSideOffset = 200
//200 represents the width of the main view when the side menu is present
If you decide to add other actions to open the menu such as a hamburger button, then just call the toggle method of DualSlideMenuViewController with the parameter of which direction the main view should move. I know its counterintuitive, but think of the parameter not as where the side view appears but where the main view is moving towards
controller.toggle('right')
//This will open the left side view and move the main view to the RIGHT (KEYWORD)
Switching views without animation
controller.toMain() // main view appears without animation
controller.toLeft() // left view appears without animation
controller.toRight() // right view appears without animation
On the other hand, if you wanted to animate to the main view with actual animations
controller.collapseAll()
If you wanted to add swipe gestures in the side menus, you can now do so
controller.addSwipeGestureInSide(rightView!, direction: .Right)
controller.addSwipeGestureInSide(leftView!, direction: .Left)

Delegate Methods

func onSwipe() {
  // Called when the user has swiped from any view
}

func didChangeView() {
  // Called when asynchronous animation has completed
}

Complete API

[Back to Top]

  // Initializers
  public convenience init(mainViewController: UIViewController, leftMenuViewController: UIViewController)
  public convenience init (mainViewController: UIViewController, rightMenuViewController: UIViewController)
  public convenience init(mainViewController: UIViewController, leftMenuViewController: UIViewController, rightMenuViewController: UIViewController) 

  /**
    Add swipe gestures in side view
    Useful when side view takes up the whole screen so the only way to navigate to home is with this swipe gesture

    - parameter viewController: the view controller that a recognizer will be added to
    - parameter direction:      the direction of type UISwipeGestureRecognizierDirection
   */
  public func addSwipeGestureInSide(viewController: UIViewController, direction: UISwipeGestureRecognizerDirection)

  /**
    Main toggle function that controls navigation of side menu

    - parameter swipeDirection: the direction of the swipe
    ex. "left" or "right" where swiping from left to right is a "right" swipe
   */
  public func toggle(swipeDirection: String)

  /**
    This is an escape method that will animate to the main view no matter what view the app is currently in

    This method will not animate the transition, so the main view will appear in view instantly
    Up to developers to decide which to use for their use case
   */
  public func toMain()

  /**
    Similar to toMain, except instantly animates to left menu
   */
  public func toLeft()

  /**
    Similar to toMain, except instantly animates to right menu
   */
  public func toRight() 

  /**
    Will move to main view from either left or right menu.
    Pretty straight forward, this is a cleaner implementation of toMain and does include animations
    Up to developers to decide to fit their use case
   */
  public func collapseAll() 

Walkthrough of new swipe gesture recognizers

[Back to Top]
Video Walkthrough

Contributions

[Back to Top] I am happy to accept any open contributions. Just fork this project, make the changes and submit a pull request.

Author

[Back to Top]

Vincent Le, vinnyoodles@gmail.com

License

[Back to Top]

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

You canā€™t perform that action at this time.