iOS drawing circle Path for percent state -
i try draw circle given percent value (like if have 25% draw quarter of circle). @ moment im able draw full circle within view. ideas problem?
code atm:
- (uibezierpath *)makecircleatlocation:(cgpoint)location radius:(cgfloat)radius { self.circlecenter = location; self.circleradius = radius; uibezierpath *path = [uibezierpath bezierpath]; [path addarcwithcenter:self.circlecenter radius:self.circleradius startangle:0.0 endangle:m_pi * 2.0 clockwise:yes]; return path; } - (void)drawcircleforlocation{ cgpoint location = cgpointzero; location.x = self.frame.size.width/2; location.y = self.frame.size.height/2; cashapelayer *shapelayer = [cashapelayer layer]; shapelayer.path = [[self makecircleatlocation:location radius:9] cgpath]; shapelayer.strokecolor = [[uicolor whitecolor] cgcolor]; shapelayer.fillcolor = nil; shapelayer.linewidth = 1.5; [self.layer addsublayer:shapelayer]; }
2 pi rad = 360° = full circle. 25% of circle = 2 pi * 25%
- (uibezierpath *)makecircleatlocation:(cgpoint)location radius:(cgfloat)radius percent:(cgfloat)percent { self.circlecenter = location; //???? self.circleradius = radius; //???? uibezierpath *path = [uibezierpath bezierpath]; [path addarcwithcenter:location radius:radius startangle:0.0 endangle:((m_pi * 2.0) * percent) clockwise:yes]; [path addlinetopoint:location]; [path closepath]; return path; }
Comments
Post a Comment