Cómo tener la rotation completa de un object circular con la animation uiview

Estoy tratando de hacer un ciclo sobre círculos parciales para lograr la animation, pero solo gira 180 grados y luego vuelve a comenzar desde 0 grados a 180 grados. Entonces, hay un salto brusco de 180 grados a 360 grados. ¿Cómo puedo rotar continuamente mi object de image circular sin saltos? Aquí está mi código actual:

UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear|UIViewAnimationOptionRepeat; [UIView animateWithDuration:ROTATE_ANIMATION_DURATION/2 delay:0 options:options animations:^{ view.transform = CGAffineTransformRotate(transform, M_PI);}//1st step of animation finished completion:^(BOOL finished) { [UIView animateWithDuration:ROTATE_ANIMATION_DURATION/2 delay:0 options:options animations:^{ view.transform = CGAffineTransformRotate(transform, M_PI);} //2nd step of animation finished completion:^(BOOL finished) {nil; }]; 

Objeto de UI de giro, la animation gira 360 grados
Deberá agregar QuartzCore Framework a su proyecto e include el

 #import QuartzCore/QuartzCore.h 

Agregar animation para object:

  CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; fullRotation.fromValue = [NSNumber numberWithFloat:0]; fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)]; fullRotation.duration = 6; fullRotation.repeatCount = 1e100f; [myview.layer addAnimation:fullRotation forKey:@"360"]; 

Encontré un código antiguo que utilizo para rotar una vista de 360 ​​grados, espero que sea de ayuda. Deberá importar QuartzCore.

 CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.zRad"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0]; rotationAnimation.duration = 3; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = INFINITY; rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; [viewToAnimate.layer addAnimation:rotationAnimation forKey:@"transform.rotation.zRad"]; 

Swift 3:

 var rotationAnimation = CABasicAnimation() rotationAnimation = CABasicAnimation.init(keyPath: "transform.rotation.z") rotationAnimation.toValue = NSNumber(value: (Double.pi * 2.0)) rotationAnimation.duration = 1.0 rotationAnimation.isCumulative = true rotationAnimation.repeatCount = 100.0 view.layer.add(rotationAnimation, forKey: "rotationAnimation") 

Aquí hay una funciones de extensión para UIView que maneja las operaciones de inicio y parada de rotation:

 extension UIView { func startRotation() { let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotation.fromValue = 0 rotation.toValue = NSNumber(value: Double.pi * 2.0) rotation.duration = 1.0 rotation.isCumulative = true rotation.repeatCount = FLT_MAX self.layer.add(rotation, forKey: "rotationAnimation") } func stopRotation() { self.layer.removeAnimation(forKey: "rotationAnimation") } } 

Ahora usando, cierre de UIView.animation:

 UIView.animate(withDuration: 0.5, animations: { button.transform = CGAffineTransform(rotationAngle: (CGFloat(Double.pi)) }) { (isHalfAnimationComplete) in UIView.animate(withDuration: 0.5) { button.transform = CGAffineTransform(rotationAngle: (CGFloat(Double.pi * 2)) } }