【发布时间】:2015-12-14 12:58:06
【问题描述】:
我有一个最初位于位置 A 的视图,以及名为 B 和 C 的另外两个位置。
此图像显示了视图的初始状态。
我想要实现的是将视图从 B 动画化到 C,但以不同的方式。
我希望动画对象从 A 开始并在 C 结束,但跳过 A→B 部分,只执行 >B→C部分。
代码应该是这样的:
// aLabel and cLabel are the labels shown in the image above
let a = aLabel.center.x
let c = cLabel.center.x
let animation = CABasicAnimation(keyPath: "position.x")
animation.duration = 3
// The animation should start in code from A
animation.fromValue = a
// And ends at C
animation.toValue = c
// Update the model layer
someView.layer.position.x = c
/* ADD SOMETHING TO MAKE THE ANIMATION
STARTS FROM B AND ENDS AT C */
我已经尝试过的
我尝试将动画偏移设置为 1.5 :
animation.timeOffset = 1.5
但它没有用。动画执行如下: B → C → A → B ,我只想要 B → C
【问题讨论】:
标签: ios swift animation core-animation cabasicanimation