我有一个动画,它应该不断旋转图像。但是它有几个问题。速度很奇怪,尽管我将它设置为不断重复,但您可以看到它是如何开始、停止然后重复的。这不应该发生。它应该是不间断的旋转。 另外,另一个问题是当动画停止时,图像由于某种原因向左移动。
这是我的代码:
func animateLogo()
{
UIView.animate(withDuration: 6.0, delay: 0.0, options: .repeat, animations: {
self.logo.transform = CGAffineTransform(rotationAngle: ((180.0 * CGFloat(Double.pi)) / 180.0))
}, completion: nil)
}
最佳答案
试试这个
func rotateView(targetView: UIView, duration: Double = 1.0) {
UIView.animate(withDuration: duration, delay: 0.0, options: .curveLinear, animations: {
targetView.transform = targetView.transform.rotated(by: CGFloat(M_PI))
}) { finished in
self.rotateView(targetView: YOUR_LOGO, duration: duration)
}
}
如何使用
self.rotateView(targetView: YOUR_LOGO, duration: duration)
关于ios - 顺时针图像旋转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49028966/