Code Monkey home page Code Monkey logo

amslidemenu's Introduction

AMSlideMenu

Sliding Menu for iOS by arturdev .

This is a simple library to create sliding menus that can be used in storyboards and support static cells.

With this library you can create 3 types of sliding menus:

  1. Slide menu with right menu only.
  2. Slide menu with left menu only.
  3. Slide menu with both left and right menus.

This repo contains project that demonstrate usage of AMSlideMenu .
This project created in Xcode 5 , so this library is fully compatible with iOS 7.
Works for both iPhone and iPad.

USAGE

You can use AMSlideMenu with both static cells and dynamic cell prototypes.

Just follow this steps:

  1. Copy AMSlideMenu/AMSlideMenu folder to your project.
  2. Make a subclass of AMSlideMenuMainViewController. Assume you made MainVC.h and MainVC.m files (like in this project).
  3. Add a UIViewController to your iPhone's or iPad's storyboard and name it's class to MainVC and embed it in UINavigationController
  4. For Left Menu:
           Add a UITableViewController to your storyboard and name it's class to any class that inherits from
           AMSlideMenuLeftTableViewController. Connect the AMSlideMenuMainViewController with your subclass with a custom        segue of type AMSlideMenuLeftMenuSegue, set the segue identifier to leftMenu.

    For Right Menu:
       Add a UITableViewController to your storyboard and name it's class to any class that inherits from
       AMSlideMenuRightTableViewController. Connect the AMSlideMenuMainViewController with your subclass with a custom        segue of type AMSlideMenuRightMenuSegue, set the segue identifier to rightMenu.

5. To add Content ViewController you have to to do the following:
       • Create your content view controller and embed it in a UINavigationController
       • Connect it to the AMSlideMenuLeftTableViewController or AMSlideMenuRightTableViewController with custom segue          AMSlideMenuContentSegue and set some identifier.
      If you want to use dynamic cells , then you have to perform segues in -tableView:didSelectRowAtIndexPath: method yourself.

6.. In MainVC.m override this methods and return segue identifiers that you setted in previous step:
      -(NSString *)segueIdentifierForIndexPathInLeftMenu:(NSIndexPath *)indexPath;
      -(NSString *)segueIdentifierForIndexPathInRightMenu:(NSIndexPath *)indexPath;

Thats it, you are done.

CUSTOMIZATION

You can easily customize slide menu by overriding needed methods in you MainVC.m , such us:

- (AMPrimaryMenu)primaryMenu;
- (NSIndexPath *)initialIndexPathForLeftMenu;
- (NSIndexPath *)initialIndexPathForRightMenu;
- (NSString *)segueIdentifierForIndexPathInLeftMenu:(NSIndexPath *)indexPath;
- (NSString *)segueIdentifierForIndexPathInRightMenu:(NSIndexPath *)indexPath;
- (void)configureLeftMenuButton:(UIButton *)button;
- (void)configureRightMenuButton:(UIButton *)button;
- (CGFloat)leftMenuWidth;
- (CGFloat)rightMenuWidth;
- (void) configureSlideLayer:(CALayer *)layer;
- (CGFloat) panGestureWarkingAreaPercent;

You cas use this methods in you MainVC.m if you want to open or close left or right menus programmatically:

- (void)openLeftMenu;
- (void)openLeftMenuAnimated:(BOOL)animated;
- (void)openRightMenu;
- (void)openRightMenuAnimated:(BOOL)animated;
- (void)closeLeftMenu;
- (void)closeLeftMenuAnimated:(BOOL)animated;
- (void)closeRightMenu;
- (void)closeRightMenuAnimated:(BOOL)animated;

If you want do add left/right menu button, or enable/disable pan gesture in you pushed view controller, then just import "UIViewController+AMSlideMenu.h" and call this methods from your pushed VC instance:
- (void)addLeftMenuButton;
- (void)addRightMenuButton;
- (void)disableSlidePanGestureForLeftMenu;
- (void)disableSlidePanGestureForRightMenu;
- (void)enableSlidePanGestureForLeftMenu;
- (void)enableSlidePanGestureForRightMenu;
e.g.
[self addLeftMenuButton];
Where self is your pushed VC.
If you want to get menu's open/close callbacks, then set MainVC's delegate property, and implement protocol named 'AMSlideMenuProtocols'.
@optional
- (void)leftMenuWillOpen;
- (void)leftMenuDidOpen;
- (void)rightMenuWillOpen;
- (void)rightMenuDidOpen;
  • (void)leftMenuWillClose;
  • (void)leftMenuDidClose;
  • (void)rightMenuWillClose;
  • (void)rightMenuDidClose;

If you want to get MainVC's instance in any content VC, then call:

AMSlideMenuMainViewController *mainVC = [self mainSlideMenu];

Don't forget to import "UIViewController+AMSlideMenu.h" in your content VC.

If you want to programmatically change content vc to any vc at indexPath in your left/right menu then call
-(void)openContentViewControllerForMenu:(AMSlideMenu)menu atIndexPath:(NSIndexPath *)indexPath;

  AMSlideMenuMainViewController *mainVC = [self mainSlideMenu];
  NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  [mainVC openContentViewControllerForMenu:AMSlideMenuRight atIndexPath:indexPath];

If you want to give deep effect to menus like in demo, then override in MainVC this funcion and return YES:

// Enabling Deepnes on left menu
- (BOOL)deepnessForLeftMenu
{
    return YES;
}

// Enabling Deepnes on left menu
- (BOOL)deepnessForRightMenu
{
    return YES;
}

SCREENSHOTS



amslidemenu's People

Contributors

arturdev 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.