TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2016 |
SPMSupports SPM | ✓ |
Maintained by Vincent Le.
Left and right slide menu to keep your main view clutter free
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.
import DualSlideMenu
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
}
let leftView = storyboard?.instantiateViewControllerWithIdentifier("LeftMenuController")
let mainView = storyboard?.instantiateViewControllerWithIdentifier("MainController")
let controller = DualSlideMenuViewController(mainViewController: mainView!, leftMenuViewController: leftView!)
controller.leftSideOffset = 200
controller.rightSideOffset = 200
//200 represents the width of the main view when the side menu is present
controller.toggle('right')
//This will open the left side view and move the main view to the RIGHT (KEYWORD)
controller.toMain() // main view appears without animation
controller.toLeft() // left view appears without animation
controller.toRight() // right view appears without animation
controller.collapseAll()
controller.addSwipeGestureInSide(rightView!, direction: .Right)
controller.addSwipeGestureInSide(leftView!, direction: .Left)
func onSwipe() {
// Called when the user has swiped from any view
}
func didChangeView() {
// Called when asynchronous animation has completed
}
// 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()
[Back to Top] I am happy to accept any open contributions. Just fork this project, make the changes and submit a pull request.
Vincent Le, [email protected]
DualSlideMenu is available under the MIT license. See the LICENSE file for more info.