ios - 核心动画 : Pause before autoreversing?

标签 ios cocoa-touch core-animation

我有一个动画,它沿着弯曲的路径然后返回动画层。我希望图层在自动反转开始之前暂停。有没有一种使用 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"];

最佳答案

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

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

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

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

相关文章:

ios - SKColor 不起作用,总是白色

iOS TabBar 图片分配

iphone - RESTful iPhone 客户端和模型层次结构

core-animation - NSWindow 增长动画(如快速查看窗口)

ios从图片链接到页面

ios - 模仿 tableView :willBeginEditingRowAtIndexPath: on UIViewController 的 UITableViewControllers 行为

iphone - 如何在应用程序内运行时切换语言?

objective-c - UIProgressView 和自定义轨迹和进度图像(iOS 5 属性)

objective-c - 具有不透明背景的 CALayer 中的文本抗锯齿

ios - 向图层添加 CAAnimation 时, "forKey"参数的用途是什么?