Skip to content

Instantly share code, notes, and snippets.

@caiguo37
Created March 2, 2013 02:55
Show Gist options
  • Save caiguo37/5069496 to your computer and use it in GitHub Desktop.
Save caiguo37/5069496 to your computer and use it in GitHub Desktop.
平面旋转
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
//http://stackoverflow.com/questions/9844925/uiview-infinite-360-degree-rotation-animation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment