Skip to content

Loading…

Allow setting of custom stroke color for TKProgressCircleView #270

Closed
wants to merge 1 commit into from

2 participants

@cpjolicoeur

No description provided.

@devinross
Owner

I made the color of the indicator be determined by the tintColor.

@devinross devinross closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 15 additions and 3 deletions.
  1. +4 −0 src/TapkuLibrary/TKProgressCircleView.h
  2. +11 −3 src/TapkuLibrary/TKProgressCircleView.m
View
4 src/TapkuLibrary/TKProgressCircleView.h
@@ -35,11 +35,15 @@
@interface TKProgressCircleView : UIView {
BOOL _twirlMode;
float _progress,_displayProgress;
+ UIColor *_stroke_color;
}
/** Initialized a new progress circle view. */
- (id) init;
+/** Initialize a new progress circle view with custom stroke color. */
+- (id)initWithStrokeColor:(UIColor *)color;
+
/** The progress displayed. Value between 0.0 and 1.0 */
@property (nonatomic,assign) float progress; // between 0.0 & 1.0
View
14 src/TapkuLibrary/TKProgressCircleView.m
@@ -37,9 +37,17 @@
@implementation TKProgressCircleView
- (id) init{
- self = [self initWithFrame:CGRectZero];
+ self = [self initWithFrame:CGRectZero];
+ _stroke_color = [UIColor whiteColor];
return self;
}
+
+- (id)initWithStrokeColor:(UIColor *)color {
+ self = [self init];
+ _stroke_color = color;
+ return self;
+}
+
- (id) initWithFrame:(CGRect)frame {
frame.size = CGSizeMake(40,40);
if(!(self = [super initWithFrame:frame])) return nil;
@@ -58,11 +66,11 @@ - (void) drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect r = CGRectInset(rect, 4, 4);
- CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
+ CGContextSetStrokeColorWithColor(context, _stroke_color.CGColor);
CGContextSetLineWidth(context, 3.0);
CGContextAddEllipseInRect(context, r);
CGContextStrokePath(context);
- CGContextSetRGBFillColor(context,1,1,1,1);
+ CGContextSetFillColorWithColor(context, _stroke_color.CGColor);
if(!_twirlMode){
CGContextAddArc(context, rect.size.width/2, rect.size.height/2, (rect.size.width/2)-7, M_PI/-2.0, ((M_PI*2.0) *_displayProgress) - M_PI/2.0 , false);
Something went wrong with that request. Please try again.