Code, Code, Revolution!
A while back I wrote about the sliding menu in the Facebook application. I was truly impressed by their application and especially the sliding menu. One of the major problems with the iPhone UI in my opinion is the lack of intuitive ways to present navigation to many functions for a single view. The sliding menu is the best implementation that adress that problem I’ve seen so far.
I actually went about building a sliding menu control with the intent to put the code on my blog. However, I didn’t finish it because I was still busy with my real job at Avantime and the iPhone application I was working on. But yesteday I got an email from a fellow iPhone developer asking if he could get some pointers in how to go about building sliding menu and to be honest I had sort of forgotten about the project all together. I spent a few hours today completing the code and adding comments to make it fit for another iPhone related blog post.
The idea behind the sliding menu is to use an UIScrollView to host the buttons and listen to the scrolling events to find the content offset of the UIScrollView and show/hide some indicator to inform the user that he/she can actually scroll the button row. I’ve recorded a short demo here:
Amazingly beautiful colors init?
The sliding menu control is initialized with a frame dictating the size of the control, the background color and an array of UIButtons. I didn’t implement the “can scroll left/right” indicator but the function exist and prints messages to the log.
Download the sample project containg the sliding menu control
With this blog I try to provide useful tips and solutions for programming .NET, Objective-C and more. My name is Björn Sållarp, and I love writing code.
It's now available on AppStore. It's free and open source. Read more about the app here: Swedish / English
Impressive Facebook 2.0 iPhone application
November 16th, 2008 at 4:34 am
[...] back later for an update on my facebook-style horizontal scroll menu. You find the code here Bookmark / Share: Tags: [...]
Billy Tobon
November 19th, 2009 at 8:24 pm
Nice job, thanks for the demo!
links for 2009-11-21 « Gatunogatuno’s Weblog
November 21st, 2009 at 9:57 am
[...] iPhone sliding menu (facebook style) | blog.sallarp.com (tags: iphone development) [...]
mayur birari
March 26th, 2010 at 9:05 am
just what i needed, thank you ,thank you very much
Yo
April 30th, 2010 at 8:24 am
what a man you are ! . .god bless you for ya great heart to share this. . cheers !
Cotutiu Lucian
August 3rd, 2010 at 10:50 am
Nice job. cheers!
Turbo
August 17th, 2010 at 7:14 pm
Very useful example – thanks very much!
ktk
August 19th, 2010 at 9:36 am
Great tutorial! Help me a lot~ Many thanks~
In advance, could you teach me how to move each button to the exact perfect and accurately location? Like iPhone Home Layouts – they can move to the specific place where they should be going to.
Like if I touch “button 2″, and “button 2″ move gracefully and automatically to the perfect location.
thanks~
KTK.
Mexidonia
October 21st, 2010 at 3:00 pm
How would you add multiples of this control? When I add a new instance things go screwy in a hurry.
Manaday
November 10th, 2010 at 3:46 pm
Thanks buddy i am very new to iOS development and searching for the same.. Keep continue to post such good articles.
Sergio Guerrera
March 12th, 2011 at 7:11 am
Do you have a more recent code example, the one you have for download doesnt seem to allow scrolling!?
Rc
April 12th, 2011 at 11:38 pm
Man you are awesome. Thanks for the quick download too. God bless you.
monish
April 26th, 2011 at 8:07 am
Thanks for such a great example but in my project the buttons are not shown [roper
Damian Modernell
May 11th, 2011 at 6:04 am
Really helped, just wha t i needed
Julius Hermosura
July 24th, 2011 at 6:12 am
Hi,
Is this still working in current version of iPhone SDK?
Because I tried running it on my iPhone simulator 4.0 and the sliding in buttons is not working.
gianluca
August 5th, 2011 at 1:52 pm
great tutorial! very useful! thanks a lot!!! it works perfectly!!!!!
vijay
August 5th, 2011 at 4:02 pm
hai i have implemented this behavior with nice looking with small amount of code
http://stackoverflow.com/questions/6955743/how-to-create-a-sliding-menu-bar-for-buttons/6957171#6957171
how to create a sliding menu bar for buttons? | Software development support, software risk,bugs for bugs, risk analysis,
December 7th, 2011 at 2:00 am
[...] http://blog.sallarp.com/iphone-sliding-menu/ [...]
Siddharthan
January 25th, 2012 at 12:24 pm
Hello will this work on iPad simulator?