我在观看图标上旋转了分钟指针,但是在动画结束时,它跳回到了起始位置。如何让它停留在停止的地方?
let rotation: CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotation.toValue = Double.pi
rotation.duration = 0.5 // or however long you want ...
rotation.isCumulative = true
watchIconMin.layer.add(rotation, forKey: "rotationAnimation")
最佳答案
如果watchIconMin是UIView的子类或类,请使用UIView动画。
UIView.animate(withDuration: 0.5, animations: {
self.watchIconMin.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
}) { (success) in
self.watchIconMin.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
}