OGeek|极客世界-中国程序员成长平台

标题: ios - 核心动画 : Pause before autoreversing? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 04:10
标题: ios - 核心动画 : Pause before autoreversing?

我有一个动画,它沿弯曲路径为图层设置动画,然后返回。我希望图层在自动反转开始之前暂停。Core Animation 有没有简单的方法来做到这一点?

这是我用来启动动画的代码。

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath"position"];
animation.duration = animationDuration;
animation.path = curvedPath;
animation.rotationMode = kCAAnimationRotateAuto;
animation.delegate = nil;
animation.autoreverses = YES;
[self.myView.layer addAnimation:animation forKey"cardAnimation"];



Best Answer-推荐答案


我能想到的在自动反转动画中暂停的唯一方法是启动一个 1/2 动画时间的计时器。

当计时器触发时,将动画速度设置为 0,然后启动另一个计时器。当第二个计时器触发时,再次将动画速度设置回 1(或之前的任何值)。如果您使用缓入缓出动画计时,那应该看起来不错,因为动画在反转之前会减慢到停止。

否则,您可能必须创建单独的正向和反向动画,为动画设置委托(delegate),并在完成方法中暂停然后启动反向动画。

关于ios - 核心动画 : Pause before autoreversing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27630289/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4