I am drawing in a uiview by subclassing a uiview and drawing code is in the
- (void)drawRect:(CGRect)rect
method. I am repeatedly calling this to get a growing effect for a line. But every time the method calls the view get cleared. Only small line ig ploted in the view my complete code is
- (void)drawRect:(CGRect)rect
{
static int i=0;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.5);
CGContextSetLineWidth(context, 10.0);
CGContextMoveToPoint(context, i, i);
CGContextAddLineToPoint(context, i+10, i+10);
NSLog(@"-----%d",i);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFillStroke);
i++;
if(i<100)
[self performSelector:@selector(setNeedsDisplay) withObject:nil afterDelay:0.033];
}
How can I make a growing effect for line