缩放图像以从左到右消失

发布于 2024-10-19 04:45:58 字数 605 浏览 6 评论 0原文

我有一个图像,我想通过将图像从左到右水平缩放到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮是我掰弯的 2024-10-26 04:45:58

我希望它从左到右缩小

在开始动画之前设置 imageName.layer.anchorPoint = CGPointMake(1.0f, 0.5f);

而且我还希望它一直缩小到 0.0,以便完全不可见。

尝试设置一个非常小但不为零的比例因子,例如 0.000001。然后,当动画完成时,从其父视图中删除该视图。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文