Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Image transition problem

Hey guys, how can make an image transition with two images. I need to transition the bucket image from scale 1.0, position of 160,100(x,y) to scale 0.5, position of 160,250(x,y) at duration of 2 and the reference point is at center of the bucket.png image.

here is the image :

first image -> http://i.imgur.com/4bYexyb.png second image is @2x -> http://i.imgur.com/UuUxJKW.png

2 Answers

See if you can use this snippet to do what you want. To handle the scaling you need a CGAffineTransform. Then in the completion block you can swap to the 1x image and apply the identity transform.

[UIView
   animateWithDuration:2.0
   animations:^{
       imageView.transform = CGAffineTransformMakeScale(0.5, 0.5);
       imageView.frame = newFrame;
   }
   completion:^(BOOL finished) {
       imageView.image = newImage;
       imageView.transform = CGAffineTransformIdentity;
   }];

Could you please give me full code because i want to study full code and as you know i'm novice in iOS development. Sometimes simple things for you is hard for me. Marshall Huss