Swift/Objective c-旋转/旋转CAShapeLayer



我正试图围绕它自己制作动画/旋转一个圆圈。确实是我试过的,但它只是在整个屏幕上旋转。。我不需要它移动,我只需要原地旋转。let circleLayer: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")

你知道它为什么在移动以及在现场旋转吗?

找到了解决方案,我只需要用不同的动画旋转视图本身:

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

享受

最新更新