Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I encountered the same issue a while ago. I do not remember the reason for that issue, but this is my solution:</p> <pre><code>/** * Incrementally rotated the arrow view by a given angle. * * @param degrees Angle in degrees. * @param duration Duration of the rotation animation. */ - (void)rotateArrowViewByAngle:(CGFloat)degrees withDuration:(NSTimeInterval)duration { CABasicAnimation *spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; spinAnimation.fromValue = [NSNumber numberWithFloat:self.currentAngle / 180.0 * M_PI]; spinAnimation.toValue = [NSNumber numberWithFloat:degrees / 180.0 * M_PI]; spinAnimation.duration = duration; spinAnimation.cumulative = YES; spinAnimation.additive = YES; spinAnimation.removedOnCompletion = NO; spinAnimation.delegate = self; spinAnimation.fillMode = kCAFillModeForwards; [self.arrowView.layer addAnimation:spinAnimation forKey:@"spinAnimation"]; self.currentAngle = degrees; } </code></pre> <p>and then you can use the delegate methods</p> <pre><code>- (void)animationDidStart:(CAAnimation *)theAnimation - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag </code></pre> <p>to rotate keep it rotating. Also, degree and duration parameters can be really high numbers... if this is enough.</p> <p>UPDATE:<br> As stated by yinkou, </p> <pre><code>spinAnimation.repeatCount = HUGE_VALF; // HUGE_VALF is defined in math.h so import it </code></pre> <p>is way better that restarting the animation in the delegate.</p> <p>PLEASE NOTE:<br> self.currentAngle is a property remembering the current final rotation. <br> I needed that to make the view rotate left and right way around.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload