[![CI Status](http://img.shields.io/travis/Giuseppe Nucifora/HamburgerButton.svg?style=flat)](https://travis-ci.org/Giuseppe Nucifora/HamburgerButton)
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.
LBHamburgerButton use QuartzCore framework, so dont forget to add this framework. ARC (iOS 5+) is also required.
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];
}
Copyright (c) 2014 Bang Nguyen
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'
Giuseppe Nucifora, [email protected]
HamburgerButton is available under the MIT license. See the LICENSE file for more info.