[英]swift rotate animation around center
我有像黑膠唱片一樣的imageView
。 我想創建旋轉 animation。 但是,如果我使用此代碼,我的黑膠唱片不會完全圍繞中心旋轉。 在這個 animation 中,我的圖像有點上下移動。 如何解決?
func startRotateView(targetView: UIView, duration: Double = 3.0) {
UIView.animate(withDuration: duration, delay: 0.0, options: .curveLinear, animations: {
targetView.transform = targetView.transform.rotated(by: CGFloat(Double.pi))
}) { finished in
self.startRotateView(targetView: targetView, duration: duration)
}
}
使用CGAffineTransform
而不是旋轉
targetView.transform = CGAffineTransform(rotationAngle: .pi)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.