[![CI Status](http://img.shields.io/travis/Tanner Nelson/HamburgerButton.svg?style=flat)](https://travis-ci.org/Tanner Nelson/HamburgerButton)
- Transitions between
Hamburger
andX
state - Interface Builder Designable
- Customizable appearance and animation
- Works like a normal UIButton
- Simple API
To run the example project, clone the repo, and run pod install
from the Example directory first. Then open Example/HamburgerButton.xcworkspace
and click run.
To make a HamburgerButton
, simply drag a UIButton
into your view and set its class to HamburgerButton
. You should see two black bars appear in place of the button in the interface.
@IBOutlet var menuButton: HamburgerButton!
@IBAction menuButtonPressed(sender: HamburgerButton) {
self.menuButton.toggle(true)
}
The menu button will toggle states every time it is tapped.
Configure the defaults to affect all HamburgerButtons
created after the defaults have been set.
HamburgerButton.lineWidth = 1.0 //make the bars thinner
HamburgerButton.size = 10 //make the bar width smaller
HamburgerButton.springDamping = 0.5 //make the animation more bouncy
HamburgerButton.springVelocity = 1.0
HamburgerButton.duration = 1.0 //make the transition slower
HamburgerButton.color = UIColor.blueColor() //make the bars blue
Initialize the HamburgerButton
using the convenience intializer to make size
s and lineWidth
s that are different than the defaults.
let frame = ...
let menuButton = init(frame, size: 20.0, lineWidth: 4.0)
All other customizable properties may be changed after the button has been initialized, such as color
and duration
.
HamburgerButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HamburgerButton"
Tanner Nelson, tanner@bluebite.com
HamburgerButton is available under the MIT license. See the LICENSE file for more info.