Skip to content

Instantly share code, notes, and snippets.

@dreampowder
Created September 28, 2015 13:04
Show Gist options
  • Save dreampowder/bb8cd80a023fbfb7ed7d to your computer and use it in GitHub Desktop.
Save dreampowder/bb8cd80a023fbfb7ed7d to your computer and use it in GitHub Desktop.
CA Spring Animation Example
- (void)animateRefreshButton:(BOOL)willAnimate{
if (willAnimate) {
[self.btnRefresh setEnabled:NO];
CASpringAnimation* springRotation = [CASpringAnimation animationWithKeyPath:@"transform.rotation.z"];
springRotation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/];
springRotation.duration = 2.0f;
springRotation.cumulative = YES;
springRotation.repeatCount = INT_MAX;
springRotation.damping = 8;
[self.btnRefresh.layer addAnimation:springRotation forKey:@"rotationAnimation"];
}else{
[self.btnRefresh setEnabled:YES];
[self.btnRefresh.layer removeAllAnimations];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment