Programming Spinning, Scaling Images & Buttons: Code Snippet
A few days ago I posted a code snippet of a couple of methods that allowed you to fade a view in and out. What I didn’t expect was a number of positive messages on youtube, but it made me realize that transforms and animations of UIViews are something that many probably haven’t played around with much. So I decided to post another method showing how scaling can be used and the interesting effects that can be generated.
Check out the video:
If you’ve studied graphics math you probably know that when scaling reflection occurs if the provided scaling factor is a negative number, and because the scaling used here is done with a 2D matrix that is how the spin effect is produced which is also accompanied by shrinking (or growing).
The method I created to do this is pretty simplistic just like the one in the previous article on fading:

The key here is the CGAffineTransformMakeScale function which performs the matrix math for us with the x and y scaling factors provided.
The project I used to create the video is here:
>>> Scaling UIViews <<<
Something you’ll notice is that zero values are not used (0.01 is used in my project is the lowest scale) this is because providing zero as the scaling factor ends up zeroing everything out and causing the view being scaled to immediately be wiped from the screen.
Check it out, and hopefully you can use it to make your apps, especially your interfaces more interesting.
Would you like to learn iPhone and iPad programming online from professional instructors who have worked for companies such as EA and Disney Mobile?
[...] I also have some examples on doing some simple animation that can be used in iPhone game development here: Easy Fading Buttons and Images Scaling Images & Button [...]