Added labelColor property to CircleChart gradeLabel
Default value is PNDeepGrey, however this didn’t always look nice. So I added a labelColor property to the CircleChart.
Showing
2 changed files
with
11 additions
and
2 deletions
| @@ -17,7 +17,8 @@ | @@ -17,7 +17,8 @@ | ||
| 17 | -(void)strokeChart; | 17 | -(void)strokeChart; |
| 18 | - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current; | 18 | - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current; |
| 19 | 19 | ||
| 20 | -@property (nonatomic, strong) UIColor * strokeColor; | 20 | +@property (nonatomic, strong) UIColor *strokeColor; |
| 21 | +@property (nonatomic, strong) UIColor *labelColor; | ||
| 21 | @property (nonatomic, strong) NSNumber * total; | 22 | @property (nonatomic, strong) NSNumber * total; |
| 22 | @property (nonatomic, strong) NSNumber * current; | 23 | @property (nonatomic, strong) NSNumber * current; |
| 23 | @property (nonatomic, strong) NSNumber * lineWidth; | 24 | @property (nonatomic, strong) NSNumber * lineWidth; |
| @@ -17,6 +17,14 @@ | @@ -17,6 +17,14 @@ | ||
| 17 | 17 | ||
| 18 | @implementation PNCircleChart | 18 | @implementation PNCircleChart |
| 19 | 19 | ||
| 20 | +- (UIColor *)labelColor | ||
| 21 | +{ | ||
| 22 | + if (!_labelColor) { | ||
| 23 | + _labelColor = PNDeepGrey; | ||
| 24 | + } | ||
| 25 | + return _labelColor; | ||
| 26 | +} | ||
| 27 | + | ||
| 20 | 28 | ||
| 21 | - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current | 29 | - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current |
| 22 | { | 30 | { |
| @@ -63,7 +71,7 @@ | @@ -63,7 +71,7 @@ | ||
| 63 | 71 | ||
| 64 | [_gradeLabel setTextAlignment:NSTextAlignmentCenter]; | 72 | [_gradeLabel setTextAlignment:NSTextAlignmentCenter]; |
| 65 | [_gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; | 73 | [_gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]]; |
| 66 | - [_gradeLabel setTextColor: PNDeepGrey]; | 74 | + [_gradeLabel setTextColor:self.labelColor]; |
| 67 | [_gradeLabel setCenter:CGPointMake(self.center.x,self.center.y)]; | 75 | [_gradeLabel setCenter:CGPointMake(self.center.x,self.center.y)]; |
| 68 | _gradeLabel.method = UILabelCountingMethodEaseInOut; | 76 | _gradeLabel.method = UILabelCountingMethodEaseInOut; |
| 69 | _gradeLabel.format = @"%d%%"; | 77 | _gradeLabel.format = @"%d%%"; |
-
Please register or login to post a comment