0
我有一個使用以(x,y)爲中心的CAShape圖層創建的圖層。我想知道如何旋轉它的中心。Swift:圍繞中心點旋轉圖層
所以在上面的圖片,我們如何旋轉的指針? CGAffineTransform?或CABasicAnimation,必須使用什麼以及如何使用(語法相同)。
我有一個使用以(x,y)爲中心的CAShape圖層創建的圖層。我想知道如何旋轉它的中心。Swift:圍繞中心點旋轉圖層
所以在上面的圖片,我們如何旋轉的指針? CGAffineTransform?或CABasicAnimation,必須使用什麼以及如何使用(語法相同)。
設置您的UIElement圖層「水平放置在容器中」&「垂直放置在容器中」首先在您的故事板中。然後,添加以下代碼。
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotateAnimation.fromValue = 0.0
rotateAnimation.toValue = CGFloat(M_PI * 2.0)
rotateAnimation.duration = 1.0
rotateAnimation.repeatCount = Float.infinity
yourlayer.addAnimation(rotateAnimation, forKey: nil)