i need implement progress bar according design :
as can see, there corner radius bar itself.
this how looks current code :
so, how that? current code:
- (void)animateprogressbartopercent:(float)percent { if (percent > 1.0f) return; int radius = 42.7f; int strokewidth = 7.f; cgcolorref color = [uicolor somecolor].cgcolor; int timeinseconds = percent * 5; cgfloat startangle = 0; cgfloat endangle = percent; cashapelayer *circle = [cashapelayer layer]; circle.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0, 2.0*radius, 2.0*radius) cornerradius:radius].cgpath; circle.position = cgpointmake(self.center.x - radius, self.center.y + strokewidth); circle.fillcolor = [uicolor clearcolor].cgcolor; circle.strokecolor = color; circle.linewidth = strokewidth; circle.strokeend = endangle; [self.layer addsublayer:circle]; cabasicanimation *drawanimation = [cabasicanimation animationwithkeypath:@"strokeend"]; drawanimation.duration = timeinseconds; drawanimation.repeatcount = 1.0; drawanimation.removedoncompletion = no; drawanimation.fromvalue = [nsnumber numberwithfloat:startangle]; drawanimation.tovalue = [nsnumber numberwithfloat:endangle]; drawanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; [circle addanimation:drawanimation forkey:@"drawcircleanimation"]; }
circle.linecap = kcalinecapround
just set property of cashapelayer
Comments
Post a Comment