swift ios 旋转动画
func animate() {
UIView.animate(withDuration: 2, delay: 0, options: .repeat) {
let transformRotation = CATransform3DMakeRotation(Double.pi, 0, 0, 1)
self.layer.transform = transformRotation
}
}
func startAnimate() {
let rotationAnimatioin = CABasicAnimation(keyPath: "transform.rotation.z")
rotationAnimatioin.toValue = Double.pi * 2.0
rotationAnimatioin.duration = 6
rotationAnimatioin.repeatCount = 999999
self.layer.add(rotationAnimatioin, forKey: "rotationAnimatioin")
}
func removeAnimate() {
self.layer.removeAllAnimations()
self.setImage(UIImage(named: "tab_play"), for: .normal)
}