Showing
4 changed files
with
33 additions
and
49 deletions
| @@ -16,14 +16,14 @@ | @@ -16,14 +16,14 @@ | ||
| 16 | self = [super initWithFrame:frame]; | 16 | self = [super initWithFrame:frame]; |
| 17 | if (self) { | 17 | if (self) { |
| 18 | // Initialization code | 18 | // Initialization code |
| 19 | - _chartLine = [CAShapeLayer layer]; | 19 | + _chartLine = [CAShapeLayer layer]; |
| 20 | - _chartLine.lineCap = kCALineCapButt; | 20 | + _chartLine.lineCap = kCALineCapButt; |
| 21 | - _chartLine.fillColor = [[UIColor whiteColor] CGColor]; | 21 | + _chartLine.fillColor = [[UIColor whiteColor] CGColor]; |
| 22 | - _chartLine.lineWidth = self.frame.size.width; | 22 | + _chartLine.lineWidth = self.frame.size.width; |
| 23 | - _chartLine.strokeEnd = 0.0; | 23 | + _chartLine.strokeEnd = 0.0; |
| 24 | - self.clipsToBounds = YES; | 24 | + self.clipsToBounds = YES; |
| 25 | [self.layer addSublayer:_chartLine]; | 25 | [self.layer addSublayer:_chartLine]; |
| 26 | - self.layer.cornerRadius = 2.0; | 26 | + self.layer.cornerRadius = 2.0; |
| 27 | } | 27 | } |
| 28 | return self; | 28 | return self; |
| 29 | } | 29 | } |
| @@ -51,7 +51,6 @@ | @@ -51,7 +51,6 @@ | ||
| 51 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 51 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 52 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 52 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; |
| 53 | pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 53 | pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; |
| 54 | - pathAnimation.autoreverses = NO; | ||
| 55 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 54 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 56 | 55 | ||
| 57 | _chartLine.strokeEnd = 1.0; | 56 | _chartLine.strokeEnd = 1.0; |
| @@ -19,9 +19,9 @@ | @@ -19,9 +19,9 @@ | ||
| 19 | if (self) { | 19 | if (self) { |
| 20 | // Initialization code | 20 | // Initialization code |
| 21 | self.backgroundColor = [UIColor whiteColor]; | 21 | self.backgroundColor = [UIColor whiteColor]; |
| 22 | - self.clipsToBounds = YES; | 22 | + self.clipsToBounds = YES; |
| 23 | - _showLabel = YES; | 23 | + _showLabel = YES; |
| 24 | - _barBackgroundColor = PNLightGrey; | 24 | + _barBackgroundColor = PNLightGrey; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | return self; | 27 | return self; |
| @@ -88,7 +88,7 @@ | @@ -88,7 +88,7 @@ | ||
| 88 | float value = [valueString floatValue]; | 88 | float value = [valueString floatValue]; |
| 89 | 89 | ||
| 90 | float grade = (float)value / (float)_yValueMax; | 90 | float grade = (float)value / (float)_yValueMax; |
| 91 | - PNBar * bar = [[PNBar alloc] init]; | 91 | + PNBar * bar; |
| 92 | if (_showLabel) { | 92 | if (_showLabel) { |
| 93 | bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - 30.0, _xLabelWidth * 0.5, chartCavanHeight)]; | 93 | bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - 30.0, _xLabelWidth * 0.5, chartCavanHeight)]; |
| 94 | }else{ | 94 | }else{ |
| @@ -99,12 +99,8 @@ | @@ -99,12 +99,8 @@ | ||
| 99 | bar.grade = grade; | 99 | bar.grade = grade; |
| 100 | [self addSubview:bar]; | 100 | [self addSubview:bar]; |
| 101 | 101 | ||
| 102 | - | ||
| 103 | index += 1; | 102 | index += 1; |
| 104 | } | 103 | } |
| 105 | - | ||
| 106 | - | ||
| 107 | - | ||
| 108 | } | 104 | } |
| 109 | 105 | ||
| 110 | @end | 106 | @end |
| @@ -22,21 +22,21 @@ | @@ -22,21 +22,21 @@ | ||
| 22 | 22 | ||
| 23 | UIBezierPath* circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x,self.center.y) radius:self.frame.size.height*0.5 startAngle:DEGREES_TO_RADIANS(270) endAngle:DEGREES_TO_RADIANS(270.01) clockwise:NO]; | 23 | UIBezierPath* circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x,self.center.y) radius:self.frame.size.height*0.5 startAngle:DEGREES_TO_RADIANS(270) endAngle:DEGREES_TO_RADIANS(270.01) clockwise:NO]; |
| 24 | 24 | ||
| 25 | - _circle = [CAShapeLayer layer]; | 25 | + _circle = [CAShapeLayer layer]; |
| 26 | - _circle.path = circlePath.CGPath; | 26 | + _circle.path = circlePath.CGPath; |
| 27 | - _circle.lineCap = kCALineCapRound; | 27 | + _circle.lineCap = kCALineCapRound; |
| 28 | - _circle.fillColor = [UIColor clearColor].CGColor; | 28 | + _circle.fillColor = [UIColor clearColor].CGColor; |
| 29 | - _circle.lineWidth = [_lineWidth floatValue]; | 29 | + _circle.lineWidth = [_lineWidth floatValue]; |
| 30 | - _circle.zPosition = 1; | 30 | + _circle.zPosition = 1; |
| 31 | - | 31 | + |
| 32 | - _circleBG = [CAShapeLayer layer]; | 32 | + _circleBG = [CAShapeLayer layer]; |
| 33 | - _circleBG.path = circlePath.CGPath; | 33 | + _circleBG.path = circlePath.CGPath; |
| 34 | - _circleBG.lineCap = kCALineCapRound; | 34 | + _circleBG.lineCap = kCALineCapRound; |
| 35 | _circleBG.fillColor = [UIColor clearColor].CGColor; | 35 | _circleBG.fillColor = [UIColor clearColor].CGColor; |
| 36 | _circleBG.lineWidth = [_lineWidth floatValue]; | 36 | _circleBG.lineWidth = [_lineWidth floatValue]; |
| 37 | _circleBG.strokeColor = PNLightYellow.CGColor; | 37 | _circleBG.strokeColor = PNLightYellow.CGColor; |
| 38 | _circleBG.strokeEnd = 1.0; | 38 | _circleBG.strokeEnd = 1.0; |
| 39 | - _circleBG.zPosition = -1; | 39 | + _circleBG.zPosition = -1; |
| 40 | 40 | ||
| 41 | [self.layer addSublayer:_circle]; | 41 | [self.layer addSublayer:_circle]; |
| 42 | [self.layer addSublayer:_circleBG]; | 42 | [self.layer addSublayer:_circleBG]; |
| @@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
| 51 | { | 51 | { |
| 52 | //Add count label | 52 | //Add count label |
| 53 | 53 | ||
| 54 | - UICountingLabel* gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)]; | 54 | + UICountingLabel *gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)]; |
| 55 | [gradeLabel setTextAlignment:NSTextAlignmentCenter]; | 55 | [gradeLabel setTextAlignment:NSTextAlignmentCenter]; |
| 56 | [gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; | 56 | [gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; |
| 57 | [gradeLabel setTextColor: PNDeepGrey]; | 57 | [gradeLabel setTextColor: PNDeepGrey]; |
| @@ -65,8 +65,8 @@ | @@ -65,8 +65,8 @@ | ||
| 65 | //Add circle params | 65 | //Add circle params |
| 66 | 66 | ||
| 67 | _circle.lineWidth = [_lineWidth floatValue]; | 67 | _circle.lineWidth = [_lineWidth floatValue]; |
| 68 | - _circleBG.lineWidth = [_lineWidth floatValue]; | 68 | + _circleBG.lineWidth = [_lineWidth floatValue]; |
| 69 | - _circleBG.strokeEnd = 1.0; | 69 | + _circleBG.strokeEnd = 1.0; |
| 70 | _circle.strokeColor = _strokeColor.CGColor; | 70 | _circle.strokeColor = _strokeColor.CGColor; |
| 71 | 71 | ||
| 72 | //Add Animation | 72 | //Add Animation |
| @@ -75,7 +75,6 @@ | @@ -75,7 +75,6 @@ | ||
| 75 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 75 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 76 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 76 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; |
| 77 | pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue]/[_total floatValue]]; | 77 | pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue]/[_total floatValue]]; |
| 78 | - pathAnimation.autoreverses = NO; | ||
| 79 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 78 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 80 | _circle.strokeEnd = [_current floatValue]/[_total floatValue]; | 79 | _circle.strokeEnd = [_current floatValue]/[_total floatValue]; |
| 81 | 80 | ||
| @@ -83,13 +82,4 @@ | @@ -83,13 +82,4 @@ | ||
| 83 | 82 | ||
| 84 | } | 83 | } |
| 85 | 84 | ||
| 86 | -/* | ||
| 87 | -// Only override drawRect: if you perform custom drawing. | ||
| 88 | -// An empty implementation adversely affects performance during animation. | ||
| 89 | -- (void)drawRect:(CGRect)rect | ||
| 90 | -{ | ||
| 91 | - // Drawing code | ||
| 92 | -} | ||
| 93 | -*/ | ||
| 94 | - | ||
| 95 | @end | 85 | @end |
| @@ -18,14 +18,14 @@ | @@ -18,14 +18,14 @@ | ||
| 18 | if (self) { | 18 | if (self) { |
| 19 | // Initialization code | 19 | // Initialization code |
| 20 | self.backgroundColor = [UIColor whiteColor]; | 20 | self.backgroundColor = [UIColor whiteColor]; |
| 21 | - self.clipsToBounds = YES; | 21 | + self.clipsToBounds = YES; |
| 22 | - _chartLine = [CAShapeLayer layer]; | 22 | + _chartLine = [CAShapeLayer layer]; |
| 23 | - _chartLine.lineCap = kCALineCapRound; | 23 | + _chartLine.lineCap = kCALineCapRound; |
| 24 | - _chartLine.lineJoin = kCALineJoinBevel; | 24 | + _chartLine.lineJoin = kCALineJoinBevel; |
| 25 | - _chartLine.fillColor = [[UIColor whiteColor] CGColor]; | 25 | + _chartLine.fillColor = [[UIColor whiteColor] CGColor]; |
| 26 | - _chartLine.lineWidth = 3.0; | 26 | + _chartLine.lineWidth = 3.0; |
| 27 | - _chartLine.strokeEnd = 0.0; | 27 | + _chartLine.strokeEnd = 0.0; |
| 28 | - _showLabel = YES; | 28 | + _showLabel = YES; |
| 29 | [self.layer addSublayer:_chartLine]; | 29 | [self.layer addSublayer:_chartLine]; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -157,7 +157,6 @@ | @@ -157,7 +157,6 @@ | ||
| 157 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 157 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 158 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 158 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; |
| 159 | pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 159 | pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; |
| 160 | - pathAnimation.autoreverses = NO; | ||
| 161 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 160 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 162 | 161 | ||
| 163 | _chartLine.strokeEnd = 1.0; | 162 | _chartLine.strokeEnd = 1.0; |
-
Please register or login to post a comment