相关疑难解决方法(0)

对于大于PI的值,CAKeyFrameAnimation不是线性的

我很难理解为什么动画不能像预期的那样工作.我在做什么是这样的:

  1. UIBezierPath使用圆弧创建一个沿此路径移动Label并为路径描边设置动画.

    //Start Point is -.pi /2 to let the Arc start at the top.
    //self.progress = Value between 0.0 and 1.0
    let path : UIBezierPath = UIBezierPath.init(arcCenter: CGPoint.init(x: self.bounds.width * 0.5, y: self.bounds.height * 0.5), 
    radius: self.bounds.width * 0.5, startAngle: -.pi / 2, endAngle: (2 * self.progress * .pi) - (.pi / 2), clockwise: true)
    return path
    
    Run Code Online (Sandbox Code Playgroud)
  2. 将此路径添加到 CAShapeLayer

    circlePathLayer.frame = bounds
    circlePathLayer.path = self.path.cgPath
    circlePathLayer.strokeStart = 0
    circlePathLayer.strokeEnd = 1
    
    Run Code Online (Sandbox Code Playgroud)
  3. 使用a为strokeEnd属性设置动画 CABasicAnimation

    let animation = CABasicAnimation(keyPath: "strokeEnd") …
    Run Code Online (Sandbox Code Playgroud)

core-animation cakeyframeanimation ios swift swift3

7
推荐指数
1
解决办法
454
查看次数

标签 统计

cakeyframeanimation ×1

core-animation ×1

ios ×1

swift ×1

swift3 ×1