Great animation with Hamburger Button

Hi, this is my very first blog post about my open source iOS control, called LBHamburgerButton. It’s first written in swift but i decided to write in Objective-C because of crashing, lagging and buggy Xcode6. Hope Apple fix it soon!

After read this post about Hamburger Button Animation (http://holko.pl/2014/07/15/hamburger-button-animation/), i started writing my own button, configurable, more complex and more type (not only back button). But easier to use.

Then i did it. I have pushed my project on GitHub. Let me know if you have any question or issue via email or twitter.

hamburgerbutton

It’s easy to use, with just 2 lines of code, one for initialization and one for animation. Like this:

Initialization:

Animation ( switchState )

As the codes above, you can see that the constructor has some params. It’s to config the hamburger lines. Very easy.

This class by default have 2 type, back and close button. But it can be easily added new type with new animation. First, you need to add new enum in .h file.

Then, take a look at keyframeAnimationsOfLineIndex:forward:

Its structure is clear. If you want to add new type, write a new case like the codes above. Then you can create animations for each line of the hamburger. Use forward param to determine the right animation. Add them to an array and return it. Done!

Now you can use this button with ease or add your own animation. Don’t forget to read the README.md file in GitHub project.

Bang Nguyen

Small things make big things.