GithubHelp home page GithubHelp logo

khalidelsayed / iospulldownmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bernardgatt/iospulldownmenu

0.0 1.0 0.0 114 KB

A pulldown menu designed for all iOS devices, it supports both navigation controllers and views, users can either pull it down or activate by tapping a button.

License: MIT License

iospulldownmenu's Introduction

iOSPullDownMenu

A pulldown menu for all iOS devices.

The pulldown menu supports both navigation controllers and views, users can either pull it down or activate by tapping a button.

iOSPullDownMenu iOSPullDownMenu Button

To connect the pulldown menu to the navigation controller

.h

#import "PulldownMenu.h"

@interface MasterNavigationController : UINavigationController<PulldownMenuDelegate> {
    PulldownMenu *pulldownMenu;
}

@property (nonatomic, retain) PulldownMenu *pulldownMenu;

@end

.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    pulldownMenu = [[PulldownMenu alloc] initWithNavigationController:self];
    [self.view insertSubview:pulldownMenu belowSubview:self.navigationBar];
    
    [pulldownMenu insertButton:@"Menu Item 1"];
    [pulldownMenu insertButton:@"Menu Item 2"];
    [pulldownMenu insertButton:@"Menu Item 3"];

    pulldownMenu.delegate = self;
    
    [pulldownMenu loadMenu];
}

Or connect the pulldown menu to a view instead of the navigation controller.

.h

#import "PulldownMenu.h"

@interface MainViewController : UIViewController<PulldownMenuDelegate, UIScrollViewDelegate> {
    PulldownMenu *pulldownMenu;
}

.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    pulldownMenu = [[PulldownMenu alloc] initWithView:self.view];
    [self.view addSubview:pulldownMenu];

    [pulldownMenu insertButton:@"Menu Item 1"];
    [pulldownMenu insertButton:@"Menu Item 2"];
    [pulldownMenu insertButton:@"Menu Item 3"];

    pulldownMenu.delegate = self;
    
    [pulldownMenu loadMenu];
}

- (IBAction)menuTap:(id)sender {
    [pulldownMenu animateDropDown];
}

Events fired by the Pulldown Menu

The component fires 2 events, #1 when a menu item is selected and #2 when the pull down is fully animated.

-(void)menuItemSelected:(NSIndexPath *)indexPath
{
    NSLog(@"%d",indexPath.item);
}

-(void)pullDownAnimated:(BOOL)open
{
    if (open)
    {
        NSLog(@"Pull down menu open!");
    }
    else
    {
        NSLog(@"Pull down menu closed!");
    }
}

Open / Close on demand

The pull down/up animation can be called on demand

From a view inside a navigation controller:

    [((MasterNavigationController *)self.navigationController).pulldownMenu animateDropDown];

From a view

    [pulldownMenu animateDropDown];

Styles

Apart from having both table view and handle exposed, a number of styling properties are available out of the box.

    cellHeight = 60;
    handleHeight = 15;
    animationDuration = 0.3f;
    topMarginPortrait = 0;
    topMarginLandscape = 0;
    cellColor = [UIColor grayColor];
    cellSelectedColor = [UIColor blackColor];
    cellFont = [UIFont fontWithName:@"GillSans-Bold" size:19.0f];
    cellTextColor = [UIColor whiteColor];
    cellSelectionStyle = UITableViewCellSelectionStyleDefault;

Bitdeli Badge

iospulldownmenu's People

Contributors

bitdeli-chef avatar

Watchers

Khalid ElSayed 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.