Increase the duration of an image scaling animation (CGAffineTransformMakeScale)

I know the code to increase the image size is:

imageView.transform = CGAffineTransformMakeScale(5f, 5f);

      

But what can I add to this to make this effect take a few seconds?

The intended effect is that it looks like the user of the application is slowing down by getting closer or closer to a painting on the wall, so I want to start with a small image and then slowly enlarge it over maybe 3 seconds.

+3


source to share


1 answer


Just wrap it in an animation block like this:



[UIView animateWithDuration:3.0 ///< or however many seconds you want
                 animations:^{
                     imageView.transform = CGAffineTransformMakeScale(5f, 5f);
                 }];

      

+4


source







All Articles