Code Snippet: Easy fading iPhone buttons, images, views

I was asked by a friend working on their first iPhone app if I could show them how to fade buttons to provide the user with visual feedback.  So I came up with this quick iPhone development tutorial using some source code that is actually from the second app that we I will be showing how to build in my iPhone development videos.

A very quick demonstration of the effect is shown in this video:
This video was embedded using the YouTuber plugin by Roy Tanck. Adobe Flash Player is required to view the video.

Fading a view on the iPhone is very easy you simply specify the ending alpha value, and duration, and commit the animations.  The views will then fade to the chosen alpha value.  Overall it’s a pretty sweet way to fade buttons, and images used in your interface especially if you’ve had to go through more complex techniques.

The code for the two methods to create the buttons is shown here: Source Code Snippet Fading Images, And Buttons On The iPhone

That’s all there is to it, it’s very plug and play so all you have to do is run the methods to perform the effect., and I’ve included some sample code with a project that has various views fading in and out based on which button is selected.  With a little bit of playing around you can make flashing images/buttons etc. 

The completed project can be downloaded here: >>> FadingViews <<<

Would you like to learn iPhone and iPad programming online from professional instructors who have worked for companies such as EA and Disney Mobile?
Click here for to find out about an interactive online iOS development course that is currently being offered at a discount.

Share and Enjoy:
  • RSS
  • Twitter
  • Facebook
  • DZone
  • HackerNews
  • del.icio.us
  • FriendFeed

Related Posts

  • Harry
    This is really simple and cool..

    Thanks a ton for sharing :)
  • Michael Bell
    So simple it's brilliant. You got me playing around with the animations now, and it is massive coolness to come from Windows programming to this and be able to do this cool stuff.
blog comments powered by Disqus