CAKeyFrameAnimation不重复
您好,我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您需要将动画的
fillMode
属性设置为kCAFillModeForwards
。这应该会在结束时间冻结动画。另一个建议(老实说,这是我通常会做的)是在设置动画后将图层本身的属性设置为其最终位置。这样,当动画被删除时,该图层仍将具有最终属性作为其模型的一部分。
I believe you need to set the
fillMode
property of your animations tokCAFillModeForwards
. 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.
重点是设置对象的目标属性。动画结束后它会跳到他们那里。
The point is to set target properties of the object. It jumps to them after finishing the animation.