CABasicAnimation将重置为初始值

CABasicAnimation将重置为初始值

本文介绍了动画完成后,CABasicAnimation将重置为初始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在旋转CALayer并在动画完成后尝试将其停在最终位置。

I am rotating a CALayer and trying to stop it at its final position after animation is completed.

但是在动画完成后它会重置到其初始位置。

But after animation completes it resets to its initial position.

(xcode docs明确表示动画不会更新属性的值。)

(xcode docs explicitly say that the animation will not update the value of the property.)

任何建议如何实现这一目标。

any suggestions how to achieve this.

推荐答案

编辑:这是答案,这是我的回答和Krishnan的结合。

Edit: Here's the answer, it's a combination of my answer and Krishnan's.

cabasicanimation.fillMode = kCAFillModeForwards;
cabasicanimation.removedOnCompletion = NO;

默认值为 kCAFillModeRemoved 。 (这是你看到的重置行为。)

The default value is kCAFillModeRemoved. (Which is the reset behavior you're seeing.)

这篇关于动画完成后,CABasicAnimation将重置为初始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 15:20