This should be simple, but I\'m having trouble rotating a UIImageView
a full 360 degrees, repeated forever.
[UIView animateWithDuration:0.5 delay:0
Christoph is already going the correct way, but there is a far better way to keep it spinning without reinvoke it in the animation delegates every time it ends. This is simply wrong.
Just set the repeatCount property of your animation to HUGE_VALF
.
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = @0.0f;
animation.toValue = @(2*M_PI);
animation.duration = 0.5f; // this might be too fast
animation.repeatCount = HUGE_VALF; // HUGE_VALF is defined in math.h so import it
[self.reloadButton.imageView.layer addAnimation:animation forKey:@"rotation"];
As stated in the documentation, this will cause the animation to repeat forever.