2014-10-28 77 views
0

我試圖在它周圍設置動畫/旋轉一圈。 確實是我所嘗試過的,但它只是在整個屏幕上旋轉..我不需要它移動,我只需要在現場旋轉。 讓circleLayer:CAShapeLayer \方法Swift/Objective c - 當場旋轉/旋轉CAShapeLayer

 vlet rotate = CABasicAnimation(keyPath: "transform.rotation.z") 
     rotate.fromValue = Float(0.0) 
     rotate.toValue = Float(2.0 * M_PI) 
     rotate.duration = 1.0 
     rotate.cumulative = true 
     rotate.repeatCount = 1 
     rotate.removedOnCompletion = false 
     rotate.fillMode = kCAFillModeForward 
     circleLayer.addAnimation(rotate, forKey: "transform.rotation.z") 

以外的任何想法,爲什麼它的移動和旋轉/當場旋轉?

+0

你加入動畫層本身,所以它旋轉整層。我認爲你正在照看CAShapeLayer中的strokeEnd屬性。 – Sandeep 2014-10-28 12:53:54

回答

0

找到了解決辦法,我只會旋轉視圖本身具有不同勢動畫:

UIView.animateWithDuration(0.95, delay: 0.0, options: UIViewAnimationOptions.CurveLinear,  animations: {() -> Void in 
      self.circleView.transform = CGAffineTransformMakeRotation(self.sumer) 
     }, completion: nil) 

享受