I'm writing a page that checks if a device has been linked to the system. The page sends requests every 2 seconds for 6 times, during that time (may be up to 10 seconds) the page shows an animating loading circle.
Here is the problem: when I press the home button and immediately reopen the app, the animation stops.
Here is what I know:
Two ways of implementing the animation:
CABasicAnimation
:CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = @(2 * M_PI); rotationAnimation.duration = 1.5; rotationAnimation.cumulative = YES; [loadingCircle.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
UIView animateWithDuration...
:- (void)rotateView:(UIView *)view { [UIView animateWithDuration:0.75 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ view.transform = CGAffineTransformRotate(view.transform, M_PI); } completion:^(BOOL finished) { if (finished) { [self rotateView:view]; } }]; } ... - viewDidLoad { ... [self rotateView:loadingCircle]; }
I know that in the first implementation, setting rotationAnimation.removedOnCompletion = NO;
will resume the animation.
My question is: when I'm using the second implementation what is the equivalent way to achieve the same effect.