Giter Site home page Giter Site logo

btsimplesidemenu's Introduction

btSimpleSideMenu

This is a simple side menu for iOS. Includes Blur background, callbacks using blocks & supports delegate patterns as well. Based on the UITableView, this menu provides a simple approach of creating a side menu for iOS apps.

btSimpleSideMenu Screenshot

Requirements

  • Xcode 5 or higher
  • Apple LLVM compiler
  • iOS 7.1 or higher
  • ARC

Demo

Build and run the btSimpleSideMenuDemo project in Xcode to see btSimpleSideMenu in action. The project by default uses left & right swipes to show and hide the menu & a doubble tap gesture to toggle the state.

Installation

  1. Drag the file btSimpleSideMenu.h / btSimpleSideMenu.m and btSimpleMenuItem.h / btSimpleMenuItem.m to your project folder.
  2. Maken an import statement for the file as #import"btSimpleSideMenu.h" .
  3. Add to your project the QuartzCore framework & Accelerate Framework & make an import statement for both.

Initialization with Delegate pattern

  1. For delegate pattern, use these method to initialize the menu with the titles & images as well, in your viewController.
-(instancetype) initWithItemTitles:(NSArray *)itemsTitle addToViewController:(id)sender;
-(instancetype) initWithItemTitles:(NSArray *)itemsTitle andItemImages:(NSArray *)itemsImage addToViewController:(UIViewController *)sender;
btSimpleSideMenu *sideMenu = [[btSimpleSideMenu alloc]initWithItemTitles:@[@"One", @"Two", @"Three", @"Four",@"Five", @"Six", @"Seven"] addToViewController:self];
[sideMenu toggleMenu];
btSimpleSideMenu *sideMenu = [[btSimpleSideMenu alloc]initWithItemTitles:@[@"One", @"Two", @"Three", @"Four",@"Five", @"Six", @"Seven"]
                                             andItemImages:@[
                                                             [UIImage imageNamed:@"icon1.jpeg"],
                                                             [UIImage imageNamed:@"icon2.jpeg"],
                                                             [UIImage imageNamed:@"icon3.jpeg"],
                                                             [UIImage imageNamed:@"icon4.jpeg"],
                                                             [UIImage imageNamed:@"icon5.jpeg"],
                                                             [UIImage imageNamed:@"icon6.jpeg"],
                                                             [UIImage imageNamed:@"icon7.jpeg"]
                                                             ]
                                       addToViewController:self];
    sideMenu.delegate = self;
    [sideMenu toggleMenu];

You can implement btSimpleSideMenuDelegate protocol to receive the following messages:

-(void)btSimpleSideMenu:(btSimpleSideMenu *)menu didSelectItemAtIndex:(NSInteger)index;
-(void)btSimpleSideMenu:(btSimpleSideMenu *)menu selectedItemTitle:(NSString *)title;

Initialization with callback Using Blocks

  1. For callback using blocks, use these method to initialize the each menu item with tiles, images & block.
    btSimpleMenuItem *item1 = [[btSimpleMenuItem alloc]initWithTitle:@"One"
                                                               image:[UIImage imageNamed:@"icon1.jpeg"]
                                                        onCompletion:^(BOOL success, btSimpleMenuItem *item) {
                                                            
                                                            NSLog(@"I am Item 1");
                                                        }];
    
    btSimpleMenuItem *item2 = [[btSimpleMenuItem alloc]initWithTitle:@"Two"
                                                               image:[UIImage imageNamed:@"icon2.jpeg"]
                                                        onCompletion:^(BOOL success, btSimpleMenuItem *item) {
                                                            
                                                            NSLog(@"I am Item 2");
                                                        }];
    
    btSimpleMenuItem *item3 = [[btSimpleMenuItem alloc]initWithTitle:@"Three"
                                                               image:[UIImage imageNamed:@"icon3.jpeg"]
                                                        onCompletion:^(BOOL success, btSimpleMenuItem *item) {
                                                            
                                                            NSLog(@"I am Item 3");
                                                        }];
    
    btSimpleSideMenu *sideMenu = [[btSimpleSideMenu alloc]initWithItem:@[item1, item2, item3]
                                                   addToViewController:self];

Contact

License

btSimpleSideMenu is available under the MIT license.

Copyright © 2014 Balram Tiwari.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

btsimplesidemenu's People

Contributors

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