iphone - iOS Animation within DrawRect() -


i'm trying animate cgcontext drawings within drawrect method of view.

code snippet

//initial attempt  [uiview animatewithduration:10  animations:^{          cgrect marker = cgrectmake(leftlinex-5.0, ycoord-5.0, 10.0, 10.0);           cgcontextsetstrokecolorwithcolor(c, _barcolor.cgcolor);           cgcontextsetfillcolorwithcolor(c, _labelcolor.cgcolor);           cgcontextfillellipseinrect(c, marker);           cgcontextstrokeellipseinrect(c, marker);      }]; 

//next approach  cgrect marker = cgrectmake(255.0, 255.0, 10.0, 10.0); uiview * markerview = [[uiview alloc] initwithframe:marker]; [self addsubview:markerview];  cgcontextaddellipseinrect(c, marker); cgcontextsetstrokecolorwithcolor(c, [uicolor redcolor].cgcolor); cgcontextsetfillcolorwithcolor(c, [uicolor bluecolor].cgcolor); cgcontextfillellipseinrect(c, marker); cgcontextstrokeellipseinrect(c, marker);  [uiview animatewithduration:3 animations:^{     markerview.alpha = 0.0;     [markerview setneedsdisplay]; }];  

what know

i think because context being drawn in current drawrect view perhaps uiview isn't aware of changes made. what's best way of approaching situation? avoid subclassing if possible.

if wondering, correct approach subclass here.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -