Skip to content

Instantly share code, notes, and snippets.

@0xc010d
Created February 21, 2012 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xc010d/1875616 to your computer and use it in GitHub Desktop.
Save 0xc010d/1875616 to your computer and use it in GitHub Desktop.
void performAnimation(UIView *view, CGFloat angle, CGFloat targetAngle);
void performAnimation(UIView *view, CGFloat angle, CGFloat targetAngle) {
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationCurveEaseOut animations:^(void) {
[view setTransform:CGAffineTransformMakeRotation(angle)];
} completion:^(BOOL finished) {
if (targetAngle > M_PI_4) {
performAnimation(view, angle + M_PI_4, targetAngle - M_PI_4);
} else
if (targetAngle > 0) {
performAnimation(view, targetAngle, 0);
}
}];
}
...
performAnimation(self.imageView, M_PI_4, 10 * M_PI_2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment