Showing
1 changed file
with
14 additions
and
3 deletions
| @@ -209,24 +209,35 @@ displayCountingLabel:(BOOL)displayCountingLabel | @@ -209,24 +209,35 @@ displayCountingLabel:(BOOL)displayCountingLabel | ||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | -(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total { | 211 | -(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total { |
| 212 | + double totalPercentageValue = [current floatValue]/([total floatValue]/100.0); | ||
| 213 | + | ||
| 214 | + if (_strokeColorGradientStart) { | ||
| 215 | + self.gradientMask.strokeEnd = _circle.strokeEnd; | ||
| 216 | + } | ||
| 217 | + | ||
| 212 | // Add animation | 218 | // Add animation |
| 219 | + if (self.displayAnimated) { | ||
| 213 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 220 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 214 | pathAnimation.duration = self.duration; | 221 | pathAnimation.duration = self.duration; |
| 215 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 222 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 216 | pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]); | 223 | pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]); |
| 217 | pathAnimation.toValue = @([current floatValue] / [total floatValue]); | 224 | pathAnimation.toValue = @([current floatValue] / [total floatValue]); |
| 218 | - _circle.strokeEnd = [current floatValue] / [total floatValue]; | ||
| 219 | 225 | ||
| 220 | if (_strokeColorGradientStart) { | 226 | if (_strokeColorGradientStart) { |
| 221 | - self.gradientMask.strokeEnd = _circle.strokeEnd; | ||
| 222 | [self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 227 | [self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 223 | } | 228 | } |
| 224 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 229 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 225 | 230 | ||
| 226 | if (_displayCountingLabel) { | 231 | if (_displayCountingLabel) { |
| 227 | - [self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:[current floatValue]/([total floatValue]/100.0) withDuration:self.duration]; | 232 | + [self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:totalPercentageValue withDuration:self.duration]; |
| 233 | + } | ||
| 234 | + | ||
| 235 | + } | ||
| 236 | + else if (_displayCountingLabel) { | ||
| 237 | + [self.countingLabel countFrom:totalPercentageValue to:totalPercentageValue withDuration:self.duration]; | ||
| 228 | } | 238 | } |
| 229 | 239 | ||
| 240 | + _circle.strokeEnd = [current floatValue] / [total floatValue]; | ||
| 230 | _current = current; | 241 | _current = current; |
| 231 | _total = total; | 242 | _total = total; |
| 232 | } | 243 | } |
-
Please register or login to post a comment