CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.f];
animation.toValue = [NSNumber numberWithFloat:M_PI * 2];
animation.duration = 1;
animation.autoreverses = NO;
animation.fillMode = kCAFillModeForwards;
animation.repeatCount = MAXFLOAT;
animation.removedOnCompletion = NO;
[self.loadingImageView.layer addAnimation:animation forKey:nil];
有时动画无效,下面的代码有效.
animation.removedOnCompletion = NO;