Get Updates By E-mail 

Article Written By:
Johann Dowa

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:
Scaling and Reflecting UI Views using CGAffineTransform


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.
 


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments