ios - CAAnimation with a CGPath using arrays of values -
i have uiview shapes drawn path, inside loop using values array radius , stroke width. blends important, switch colours (ignore rgb macro).
what want animate oldshaperadius
values newshaperadius
affecting radius of arc , strokewidth
of strokedarc
.
now have looked @ lot of examples of core animation, can't see how affect drawing of effects have below, , how work calayers?
//my uiview #import "quartzcore/calayer.h" #define degreestoradians( degrees ) ( ( degrees ) / 180.0 * m_pi ) - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { self.strokewidth=38.0f; self.radius=47.0f; oldshaperadius=[[nsmutablearray alloc] initwithobjects:[nsnumber numberwithfloat:1], [nsnumber numberwithfloat:1], [nsnumber numberwithfloat:1.0], [nsnumber numberwithfloat:1], nil]; newshaperadius=[[nsmutablearray alloc] initwithobjects:[nsnumber numberwithfloat:0.6], [nsnumber numberwithfloat:0.9], [nsnumber numberwithfloat:1.0], [nsnumber numberwithfloat:0.5], nil]; } } - (void)drawrect:(cgrect)rect { (int i=0; i<4; i++) { uicolor *shapecolor; switch (i) { case 0: shapecolor=uicolorfromrgb(category_color_blue); break; case 1: shapecolor=uicolorfromrgb(category_color_green); break; case 2: shapecolor=uicolorfromrgb(category_color_pink); break; case 3: shapecolor=uicolorfromrgb(category_color_yellow); break; default: break; } cgmutablepathref arc = cgpathcreatemutable(); cgpathaddarc(arc, null, 160.0f,85, radius*[[oldshaperadius objectatindex:i] floatvalue], degreestoradians(90*i), degreestoradians(90*(i+1)), no); cgpathref strokedarc =cgpathcreatecopybystrokingpath(arc, null, strokewidth*[[oldshaperadius objectatindex:i] floatvalue], kcglinecapround,kcglinejoinround,0.0f); context = uigraphicsgetcurrentcontext(); cgcontextsetblendmode(context, kcgblendmodemultiply); cgcontextaddpath(context, strokedarc); cgcontextsetfillcolorwithcolor(context, shapecolor.cgcolor); cgcontextdrawpath(context, kcgpathfill); } }
oh lords of stackoverflow may have please. high lord david rönnqvist around haha. many in advance.
Comments
Post a Comment