Kevin

Merge pull request #158 from dredful/master

Added a method to allow the update of both the current and the total for...
... ... @@ -23,6 +23,7 @@ typedef NS_ENUM (NSUInteger, PNChartFormatType) {
- (void)strokeChart;
- (void)growChartByAmount:(NSNumber *)growAmount;
- (void)updateChartByCurrent:(NSNumber *)current;
- (void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total;
- (id)initWithFrame:(CGRect)frame
total:(NSNumber *)total
current:(NSNumber *)current
... ...
... ... @@ -206,13 +206,20 @@ displayCountingLabel:(BOOL)displayCountingLabel
-(void)updateChartByCurrent:(NSNumber *)current{
[self updateChartByCurrent:current
byTotal:_total];
}
-(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total {
// Add animation
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = self.duration;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]);
pathAnimation.toValue = @([current floatValue] / [_total floatValue]);
_circle.strokeEnd = [current floatValue] / [_total floatValue];
pathAnimation.toValue = @([current floatValue] / [total floatValue]);
_circle.strokeEnd = [current floatValue] / [total floatValue];
if (_strokeColorGradientStart) {
self.gradientMask.strokeEnd = _circle.strokeEnd;
... ... @@ -221,10 +228,11 @@ displayCountingLabel:(BOOL)displayCountingLabel
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
if (_displayCountingLabel) {
[self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:fmin([current floatValue], [_total floatValue]) withDuration:self.duration];
[self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:fmin([current floatValue], [total floatValue]) withDuration:self.duration];
}
_current = current;
_total = total;
}
@end
@end
\ No newline at end of file
... ...