GithubHelp home page GithubHelp logo

jacksonbradley / facebookmenubutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carlinyuen/facebookmenubutton

0.0 2.0 0.0 289 KB

My shot at recreating Facebook Paper's hamburger menu button. Keywords: iOS, objective-c, objc, Xcode, paper, facebook, menu, hamburger, button.

License: MIT License

Objective-C 100.00%

facebookmenubutton's Introduction

FacebookMenuButton

My shot at recreating Facebook Paper's hamburger menu button. Keywords: iOS, objective-c, objc, Xcode, paper, facebook, menu, hamburger, button.

Requirements

  • You'll need to have the QuartzCore library imported into your project.

Demo

  • See the FacebookMenuButtonExample project in the repo. It has an example of a button added through IB as well as one created in code.

Usage

  1. Import the button into your view controller: #import "FacebookMenuButton.h"

  2. Create and add an instance of the button (you can also do this in IB):

    FacebookMenuButton *menuButton = [[FacebookMenuButton alloc] 
    	initWithFrame:CGRectMake(0, 0, 44, 44)];
    menuButton.center = self.view.center;
    [self.view addSubview:menuButton];
    
  3. Add a target for the button when pressed, and set the button as selected when you want the animation to fire:

    [menuButton addTarget:self action:@selector(menuSelected:) 
    	forControlEvents:UIControlEventTouchUpInside];
    
    ...
    
    - (IBAction)menuSelected:(UIButton *)sender {
    	sender.selected = !sender.selected;
    }
    
  4. That's it! You're done. Bonus points for customizing your button with the following properties:

    /** Color for the menu bars */
    @property (nonatomic, strong) UIColor *barTint;
    
    /* Width of the menu bars */
    @property (nonatomic, assign) NSInteger barWidth;
    
    /* Height or thickness of the menu bars */
    @property (nonatomic, assign) NSInteger barHeight;
    
    /* Space between the menu bars */
    @property (nonatomic, assign) NSInteger barSpacing;
    
    /* Duration of the animation when selected */
    @property (nonatomic, assign) NSTimeInterval animationDuration;
    

Notes

  • If you're using this in Interface Builder (IB), you can drag a UIButton and simply set its Custom Class to the Facebook Button. However, you'll also want to set the type to Custom instead of the default System or you'll get an annoying blue highlight when the button is selected.

Inspiration

From Daniel Strunk's HTML5/CSS3 version of the animation: http://dstrunk.com/emulating-facebook-papers-menu-animation/

License

MIT

facebookmenubutton's People

Contributors

carlinyuen avatar

Watchers

James Cloos 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.