伙计我有以下代码来生成bezierpath
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
有人可以帮我解决这个问题吗:)
答案 0 :(得分:1)
来自:https://github.com/angular/angular/issues/11023
使用继承的init(keyPath :)方法创建CABasicAnimation实例,指定要在渲染树中设置动画的属性的关键路径。
您想要的示例:
let animation = CABasicAnimation(keyPath: "position")
animation.fromValue = [startX, startY]
animation.toValue = [destinationX, destinationY]