I have an image that I would like to make disappear by scaling the image to 0.0 horizontal from left to right.
First I tried this code, which makes the image grow very large and twirl around the screen before disappearing:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.6];
imageName.transform = CGAffineTransformMakeScale(0.0, 1.0);
[UIView commitAnimations];
Then I changed the transformation to scale(0.1, 1.0)
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.6];
imageName.transform = CGAffineTransformMakeScale(0.1, 1.0);
[UIView commitAnimations];
This creates exactly the effect that I want, except that it shrinks to 0.1 horizontal scale from both the left and right sides, meeting in the middle. I want it to shrink from left to right, and I also want it to shrink all the way to 0.0 so that it is completely invisible.
Any help would be greatly appreciated - thanks so much!
Set
imageName.layer.anchorPoint = CGPointMake(1.0f, 0.5f);
before you start the animation.Try setting a scale factor that is very small but not zero, such as
0.000001
. Then, when the animation is finished, remove the view from its superview.