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:
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:
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 <<<
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.
[...] have some examples on doing some simple animation that can be used in iPhone game development here: Easy Fading Buttons and Images Scaling Images & [...]
This is really simple and cool..
Thanks a ton for sharing