如何在 Swift 中将旋转速度降低到 0?

How would I lower the speed of the rotation to 0 in Swift?

我有这段代码可以旋转我的图像视图,但是当我按下暂停按钮时,我希望旋转速度为 0。我该怎么做?

@IBAction func playButtonL(sender: AnyObject) {

    rotation.toValue = NSNumber(double: M_PI * 2)
    rotation.duration = 2
    rotation.cumulative = true
    rotation.repeatCount = FLT_MAX
    self.leftCircleImageView.layer.addAnimation(rotation, forKey: "rotationAnimation")
}


@IBAction func pauseButtonR(sender: AnyObject) {


}

要减少动画时间,您可以使用

rotation.duration = 2

要停止重置其状态默认值,您可以使用

cabasicanimation.removedOnCompletion = NO;

cabasicanimation.fillMode = kCAFillModeForwards;

答案学分和参考:

CABasicAnimation resets to initial value after animation completes

希望对您有所帮助!如果您需要任何进一步的帮助,请告诉我。