如何使对象(例如图像)永远旋转?
UIView.animateWithDuration(2.0, animations: ({
self.Cube.transform = CGAffineTransformMakeRotation(320)
}))
有没有人有解决方案,真的很感激一些帮助。
答案 0 :(得分:0)
尝试此功能可永久旋转图层。
func rotateLayer(layer:CALayer,duration:CFTimeInterval){
let animation = CABasicAnimation(keyPath: "transform.rotation");
animation.fromValue = 0;
animation.duration = duration;
animation.toValue = CGFloat(M_PI*2);
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear);
animation.repeatCount = Float.infinity;
layer.addAnimation(animation, forKey: "rotation");
}
用法(持续时间是图层旋转360度所需的时间):
rotateLayer(subView.layer, duration: 2);