2017-01-03 16 views
0

家伙动画圆角矩形我有下面的代码产生bezierpath与CoreAnimation

firstLine.path = UIBezierPath(roundedRect: CGRect(x: frameSize.width/2.2, y: frameSize.height/2.6, width: 4, height: 4), cornerRadius: 10).cgPath 

我尝试通过X值和回原来的位置将其移动到屏幕右侧的动画于firstLine。但我不知道在动画中keyPath使用什么。

let animation = CABasicAnimation(keyPath: "??") 
animation.toValue = // this should be the position to move? 
animation.duration = 0.5 // duration of the animation 
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) // animation curve is Ease Out 
animation.fillMode = kCAFillModeBoth // keep to value after finishing 
animation.isRemovedOnCompletion = false // don't remove after finishing 
animation.autoreverses = true 
animation.repeatCount = HUGE 

有人可以帮助我走出这个:)

回答

1

来源:https://developer.apple.com/reference/quartzcore/cabasicanimation

您使用继承的init(:)的keyPath方法创建CABasicAnimation的实例,指定的关键路径要在渲染树中进行动画的属性。你想要什么

例子:

let animation = CABasicAnimation(keyPath: "position") 
animation.fromValue = [startX, startY] 
animation.toValue = [destinationX, destinationY] 
+0

位置的keyPath以某种方式不工作的bezierpath。 – Reshad

+0

@Reshad你可以添加你用来移动贝塞尔路径的代码吗? –