Skip to content

Instantly share code, notes, and snippets.

@bouchtaoui-dev
Created October 10, 2016 12:52
Show Gist options
  • Select an option

  • Save bouchtaoui-dev/4a96c146d103996b29faab87ec474d93 to your computer and use it in GitHub Desktop.

Select an option

Save bouchtaoui-dev/4a96c146d103996b29faab87ec474d93 to your computer and use it in GitHub Desktop.
- (void) startRotatingWithDuration: (double) duration {
NSString *animKey = @"rotation";
if([self.layer animationForKey: animKey] == nil) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath: @"transform.rotation"];
animation.duration = duration;
animation.repeatCount = INFINITY;
/*animation.fromValue = [NSNumber numberWithFloat: 0.0];*/
animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
[self.layer addAnimation: animation forKey: animKey];
}
}
- (void) stopRotation {
NSString *animKey = @"rotation";
if([self.layer animationForKey: animKey] != nil) {
[self.layer removeAnimationForKey: animKey];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment