Giter Site home page Giter Site logo

nvslidemenucontroller's Introduction

NVSlideMenuController

A slide menu done right.

Requirements

  • You can use ARC or not, this library supports both
  • iOS 5.0+ (since UIViewController containment API is used)

Usage

  • Drop lib/NVSlideMenuController/NVSlideMenuController.{h|m} in your project
  • Add QuartzCore.framework
  • (optional) set -fno-objc-arc to NVSlideMenuController.m if you use ARC

Create a slide menu

UIViewController *menuViewController = ... ; // Your menu view controller
UIViewController *contentViewController = ... ; // The initial content view controller (home page ?)

NVSlideMenuController *slideMenuController = [[NVSlideMenuController alloc] initWithMenuViewController:menuViewController andContentViewController:contentViewController];

self.window.rootViewController = slideMenuController; // Assuming you are in app delegate did finish launching

Change & show new content from the menu

// Inside your menuViewController
UIViewController *newContentViewController = ... ; // Create & configure your new content view controller (as usual)
[self.slideMenuController closeMenuBehindContentViewController:newContentViewController animated:YES completion:nil];

Change the slide direction

You can specify the slide direction by setting the slideDirection property to NVSlideMenuControllerSlideFromLeftToRight or NVSlideMenuControllerSlideFromRightToLeft. The views will update accordingly if needed (look at the demo app for a taste). You can also animate the change.

// Inside your view controller (menu or content)
[self.slideMenuController setSlideDirection:NVSlideMenuControllerSlideFromRightToLeft animated:YES];
// or more simply...
self.slideMenuController.slideDirection = NVSlideMenuControllerSlideFromRightToLeft; // this one will not animate

Enable/Disable the pan gesture

You could need to disable the pan gesture, for example when your content view controller has a table view with reorder control (see issue #2).

// For example when your view controller enter in editing mode
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
	[super setEditing:editing animated:animated];

	if (editing)
		self.slideMenuController.panGestureEnabled = NO;
}

NVSlideMenuController callbacks

The library provides 4 methods through a UIViewController category. You can override them to manage the slide in/out of the content view controller. It is best described by the provided demo app.

@interface UIViewController (NVSlideMenuControllerCallbacks)

- (void)viewWillSlideIn:(BOOL)animated inSlideMenuController:(NVSlideMenuController *)slideMenuController;
- (void)viewDidSlideIn:(BOOL)animated inSlideMenuController:(NVSlideMenuController *)slideMenuController;
- (void)viewWillSlideOut:(BOOL)animated inSlideMenuController:(NVSlideMenuController *)slideMenuController;
- (void)viewDidSlideOut:(BOOL)animated inSlideMenuController:(NVSlideMenuController *)slideMenuController;

@end

For more have a look at the demo app ;-]

What's next ?

  • Support Storyboard
  • iPad support done right, can already be done according to the contentViewWidthWhenMenuIsOpen property

Author

Nicolas VERINAUD (@nverinaud)

License

See LICENSE.md.

nvslidemenucontroller's People

Contributors

alex-cellcity avatar nverinaud avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.