How to draw a pie chart based on the marks percentage in ios? -
i working on 1 of school application. in which, based on percentage achieved student respective piechart should drawn animation.
for example, if student got 50%, pie chart needs filled 50% animation.
can please me on this. used below code,
// set shape of circle int radius = 60; cashapelayer *circle = [cashapelayer layer]; // make circular shape circle.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0, 2.0*radius, 2.0*radius) cornerradius:radius].cgpath; // center shape in self.view circle.position = cgpointmake(cgrectgetmidx(self.view.frame)-radius, cgrectgetmidy(self.view.frame)-radius); // configure apperence of circle circle.fillcolor = [uicolor clearcolor].cgcolor; circle.strokecolor = [uicolor redcolor].cgcolor; circle.linewidth = 10; // add parent layer [self.view.layer addsublayer:circle]; // configure animation cabasicanimation *drawanimation = [cabasicanimation animationwithkeypath:@"strokeend"]; drawanimation.duration = 10.0; // "animate on 10 seconds or so.." drawanimation.repeatcount = 1.0; // animate once.. // animate no part of stroke being drawn entire stroke being drawn drawanimation.fromvalue = [nsnumber numberwithfloat:0.0f]; drawanimation.tovalue = [nsnumber numberwithfloat:0.75f]; // experiment timing appearence way want drawanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneasein]; // add animation circle [circle addanimation:drawanimation forkey:@"drawcircleanimation"];
i stop animation @ 50%.
please use circle.strokeend = 0.5f;
it automatically stops @ 50%, if give 1.0f goes 100%
Comments
Post a Comment