完成后未删除时如何重用CABasicAnimation

完成后未删除时如何重用CABasicAnimation

本文介绍了完成后未删除时如何重用CABasicAnimation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多人都在谈论使用CABasicAnimation对象之后。

Lots of people are talking about keeping an CABasicAnimation object around after it has been used.

因此,通过设置

动画完成后,动画对象将保持附着在图层上。我该如何在不创建新的CABasicAnimation的情况下再次重新启动该动画?

the animation object keeps attached to the layer when the animation is complete. How would I re-launch this animation again without creating a new CABasicAnimation?

保持该对象的意义何在?我知道的唯一好处是,我们可以将removeOnCompletion = NO设置为kCAFillModeForwards,以便Core Animation不会将视觉表示恢复为CALayer中的模型值。

What's the point of keeping this object around? The only benefit I know is that we can set removedOnCompletion = NO and set kCAFillModeForwards so that Core Animation does not revert the visual representation back to the model values in the CALayer.

但是如何像每个人都在谈论的那样重新使用动画?

But how to re-use the animation, like everyone is talking about?

推荐答案

尝试一下:


  1. 使用

要在以后获得对它的引用,请调用

To get a reference to it later, call [layer animationForKey:@"myKey"]

阅读解释了如何暂停和恢复(重新启动)动画。

Read this note from Apple which explains how to pause and resume (restart) animations.

这篇关于完成后未删除时如何重用CABasicAnimation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:26