CAKeyFrameAnimation不重复

发布于 2024-12-23 14:49:21 字数 314 浏览 1 评论 0原文

您好,我有一个 CAKeyFrameAnimation 比例,它使对象从全尺寸 (1) 淡出到几乎没有 (0.01)

然后这被称为:

- (void)animationDidStop:(CAKeyframeAnimation *)anim finished:(BOOL)flag
{

 [self setHidden:YES];

}

它似乎隐藏了对象,但在使其再次以全尺寸重新显示之前不会隐藏瞬间,这会破坏淡入淡出到小/无效果:P

如何阻止动画返回到调用“animationDidStop”的第 1 帧?谢谢!

Hi I have a CAKeyFrameAnimation scale, that makes an object fade down from full size (1) to near nothing (0.01)

Then this is called:

- (void)animationDidStop:(CAKeyframeAnimation *)anim finished:(BOOL)flag
{

 [self setHidden:YES];

}

It seems to hide the object, but not before making it re-appear again as full sized for a split second, which ruins the fade to small/nothing effect :P

How do I stop the animation from going back to frame 1 for the "animationDidStop" is called? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

眼泪都笑了 2024-12-30 14:49:21

我相信您需要将动画的 fillMode 属性设置为 kCAFillModeForwards。这应该会在结束时间冻结动画。

另一个建议(老实说,这是我通常会做的)是在设置动画后将图层本身的属性设置为其最终位置。这样,当动画被删除时,该图层仍将具有最终属性作为其模型的一部分。

I believe you need to set the fillMode property of your animations to kCAFillModeForwards. That should freeze the animations at their end time.

Another suggestion (and honestly, this is what I'd usually do) is just set the properties of the layer itself to their final position after you've set up the animation. That way when the animation is removed, the layer will still have the final properties as part of its model.

风透绣罗衣 2024-12-30 14:49:21
  1. 您可以设置 .scale 对象属性而不是 CAKeyframeAnimation。
  2. 创建 CAKeyframeAnimation 后,您可以禁用动画并设置目标比例。
  3. 您可以在animationDidStop方法中设置比例(0.1)(不确定是否有效)

重点是设置对象的目标属性。动画结束后它会跳到他们那里。

  1. You can set .scale object property instead of CAKeyframeAnimation.
  2. You can disable animations and set target scale after creating CAKeyframeAnimation.
  3. You can set scale (0.1) in animationDidStop method (do not sure if it will work)

The point is to set target properties of the object. It jumps to them after finishing the animation.

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