答案 0 :(得分:0)
Last night i solved this,but it's not perfect First,creat an animation:
- (void)initAnimation{
[CATransaction begin];
CGFloat angle = 1000000 * 360 * M_PI/180.0;
refreshAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
refreshAnimation.byValue = @(angle);
refreshAnimation.duration = 1.0 * 1000000;
refreshAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
refreshAnimation.removedOnCompletion = YES;
[CATransaction commit];
}
Second,before send request, add the animation to the imageView:
- (void)sendRequst{
[refreshImageView.layer addAnimation:refreshAnimation forKey:@"rotationAnimation"];
[self sendRequstToSever];
}
Finally,when the server feedback,remove the animation and set the imagView to the original position:
- (void)changeAnimationStatus{
[refreshImageView.layer removeAnimationForKey:@"rotationAnimation"];
[UIView animateWithDuration:0.30 animations:^{
refreshImageView.transform = CGAffineTransformRotate(self.view.transform, 0.0);
}];}
答案 1 :(得分:0)
CGFloat angle = 2 * M_PI;
refreshAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
refreshAnimation.delegate = self;
refreshAnimation.removedOnCompletion = NO;
refreshAnimation.repeatCount = CGFLOAT_MAX;
refreshAnimation.additive = YES;
refreshAnimation.byValue = @(angle);
refreshAnimation.duration = 0.9 ;
refreshAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animationStamp = [[NSDate date] timeIntervalSince1970];
[btn.layer addAnimation:refreshAnimation forKey:@"rotationAnimation"];
然后用时间来解决这个问题