Skip to content

Instantly share code, notes, and snippets.

@nakiostudio
Created June 8, 2015 15:17
Show Gist options
  • Save nakiostudio/9dc1d8eed7f6540540a2 to your computer and use it in GitHub Desktop.
Save nakiostudio/9dc1d8eed7f6540540a2 to your computer and use it in GitHub Desktop.
- (void)reloadAnimated:(BOOL)animated withCompletionBlock:(void(^)())completionBlock
{
FWTPieChartLayer *pieLayer = self.containerLayer.sublayers.firstObject;
[CATransaction begin];
[CATransaction setCompletionBlock:completionBlock];
[CATransaction setDisableActions:YES];
CABasicAnimation *animation = (CABasicAnimation *)[pieLayer actionForKey:@"animationCompletionPercent"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.duration = self.animationDuration;
animation.fromValue = animated ? @0.f : @1.f;
animation.toValue = @1.f;
animation.byValue = @0.1f;
[pieLayer setAnimationCompletionPercent:((NSNumber*)animation.toValue).floatValue];
[pieLayer addAnimation:animation forKey:@"animationCompletionPercent"];
[CATransaction commit];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment