Created
September 28, 2015 13:04
-
-
Save dreampowder/bb8cd80a023fbfb7ed7d to your computer and use it in GitHub Desktop.
CA Spring Animation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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