缩放图像以从左到右消失
我有一个图像,我想通过将图像从左到右水平缩放到 0.0 来使其消失。
首先,我尝试了这段代码,它使图像变得非常大,并在消失之前在屏幕上旋转:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.6];
imageName.transform = CGAffineTransformMakeScale(0.0, 1.0);
[UIView commitAnimations];
然后我将转换更改为scale(0.1, 1.0)
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.6];
imageName.transform = CGAffineTransformMakeScale(0.1, 1.0);
[UIView commitAnimations];
这正是我想要的效果,除了它缩小到0.1水平比例从左右两侧,在中间相遇。我希望它从左到右缩小,我还希望它一直缩小到0.0,这样就完全看不见了。
任何帮助将不胜感激 - 非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在开始动画之前设置
imageName.layer.anchorPoint = CGPointMake(1.0f, 0.5f);
。尝试设置一个非常小但不为零的比例因子,例如
0.000001
。然后,当动画完成时,从其父视图中删除该视图。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.