Skip to content

giuseppenucifora/HamburgerButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HamburgerButton

[![CI Status](http://img.shields.io/travis/Giuseppe Nucifora/HamburgerButton.svg?style=flat)](https://travis-ci.org/Giuseppe Nucifora/HamburgerButton) Version License Platform

Overview

LBHamburgerButton is an iOS control that displays 3 lines (hamburger) and other icon (back, close...) without using image. It has a beautiful, clean and smooth transition between 2 state like Google Material Design or "close button" of Paper app.

Requirement

LBHamburgerButton use QuartzCore framework, so dont forget to add this framework. ARC (iOS 5+) is also required.

How to use

First, you need to copy 2 files LBHamburgerButton.h/.m to your project. Then, import them to your class

#import "LBHamburgerButton.h"

This is a sub-class of UIButton. So you can init a simple button and call set-up method:

buttonHamburger = [[LBHamburgerButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[buttonHamburger setUpHamburgerWithType:LBHamburgerButtonTypeCloseButton
lineWidth:50
lineHeight:50/6
lineSpacing:5
lineCenter:CGPointMake(50, 50)
color:[UIColor whiteColor]];


or use full contructor like this:


```objc
buttonHamburger = [[LBHamburgerButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)
withHamburgerType:LBHamburgerButtonTypeCloseButton
lineWidth:50
lineHeight:50/6
lineSpacing:5
lineCenter:CGPointMake(50, 50)
color:[UIColor whiteColor]];

Set other propertises, add target add it to view like UIButton.

[buttonHamburger setCenter:CGPointMake(120, 120)];
[buttonHamburger setBackgroundColor:[UIColor blackColor]];
[buttonHamburger addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:buttonHamburger];

When you want to switch state, just call switchState.

- (void)buttonPressed:(id)sender {
LBHamburgerButton* btn = (LBHamburgerButton*)sender;
[btn switchState];
}

MIT License

Copyright (c) 2014 Bang Nguyen

Installation

HamburgerButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'HamburgerButton' , :git => 'https://github.com/giuseppenucifora/HamburgerButton.git'

Author

Giuseppe Nucifora, [email protected]

License

HamburgerButton is available under the MIT license. See the LICENSE file for more info.