开发者

Scaling an image to disappear from left to right

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 = CGAffineTransfo开发者_JAVA技巧rmMakeScale(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!


I want it to shrink from left to right

Set imageName.layer.anchorPoint = CGPointMake(1.0f, 0.5f); before you start the animation.

and I also want it to shrink all the way to 0.0 so that it is completely invisible.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜