Continuous updating of PNCircleChart
In order to update one PNCircleChart which is made previously, gradeLabel has to be private property of PNCircleChart. Bacause I don't want previous gradeLabel to be kept on the UIView for the above purpose, I wrote this patch. Please consider this specification.
Showing
1 changed file
with
16 additions
and
9 deletions
| @@ -9,6 +9,12 @@ | @@ -9,6 +9,12 @@ | ||
| 9 | #import "PNCircleChart.h" | 9 | #import "PNCircleChart.h" |
| 10 | #import "UICountingLabel.h" | 10 | #import "UICountingLabel.h" |
| 11 | 11 | ||
| 12 | +@interface PNCircleChart () { | ||
| 13 | + UICountingLabel *_gradeLabel; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +@end | ||
| 17 | + | ||
| 12 | @implementation PNCircleChart | 18 | @implementation PNCircleChart |
| 13 | 19 | ||
| 14 | 20 | ||
| @@ -42,6 +48,8 @@ | @@ -42,6 +48,8 @@ | ||
| 42 | 48 | ||
| 43 | [self.layer addSublayer:_circle]; | 49 | [self.layer addSublayer:_circle]; |
| 44 | [self.layer addSublayer:_circleBG]; | 50 | [self.layer addSublayer:_circleBG]; |
| 51 | + | ||
| 52 | + _gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)]; | ||
| 45 | 53 | ||
| 46 | } | 54 | } |
| 47 | 55 | ||
| @@ -53,16 +61,15 @@ | @@ -53,16 +61,15 @@ | ||
| 53 | { | 61 | { |
| 54 | //Add count label | 62 | //Add count label |
| 55 | 63 | ||
| 56 | - UICountingLabel *gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)]; | 64 | + [_gradeLabel setTextAlignment:NSTextAlignmentCenter]; |
| 57 | - [gradeLabel setTextAlignment:NSTextAlignmentCenter]; | 65 | + [_gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; |
| 58 | - [gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; | 66 | + [_gradeLabel setTextColor: PNDeepGrey]; |
| 59 | - [gradeLabel setTextColor: PNDeepGrey]; | 67 | + [_gradeLabel setCenter:CGPointMake(self.center.x,self.center.y)]; |
| 60 | - [gradeLabel setCenter:CGPointMake(self.center.x,self.center.y)]; | 68 | + _gradeLabel.method = UILabelCountingMethodEaseInOut; |
| 61 | - gradeLabel.method = UILabelCountingMethodEaseInOut; | 69 | + _gradeLabel.format = @"%d%%"; |
| 62 | - gradeLabel.format = @"%d%%"; | ||
| 63 | 70 | ||
| 64 | 71 | ||
| 65 | - [self addSubview:gradeLabel]; | 72 | + [self addSubview:_gradeLabel]; |
| 66 | 73 | ||
| 67 | //Add circle params | 74 | //Add circle params |
| 68 | 75 | ||
| @@ -80,7 +87,7 @@ | @@ -80,7 +87,7 @@ | ||
| 80 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 87 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 81 | _circle.strokeEnd = [_current floatValue]/[_total floatValue]; | 88 | _circle.strokeEnd = [_current floatValue]/[_total floatValue]; |
| 82 | 89 | ||
| 83 | - [gradeLabel countFrom:0 to:[_current floatValue]/[_total floatValue]*100 withDuration:1.0]; | 90 | + [_gradeLabel countFrom:0 to:[_current floatValue]/[_total floatValue]*100 withDuration:1.0]; |
| 84 | 91 | ||
| 85 | } | 92 | } |
| 86 | 93 |
-
Please register or login to post a comment