It is important to know that you must make your actual drawing in drawRect:yours UIView. So the method renderLineFromPoint:toPoint:in your code should just create an array of strings and tell the browser to redraw every time, something like this:
- (void)renderLineFromPoint:(CGPoint)from toPoint:(CGPoint)to
{
[lines addObject:[Line lineFrom:from to:to]];
[self setNeedsDisplay];
}
This assumes that you have a Line class that has 2 CGPointproperties. Yours drawRect:might look something like this:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
for (Line *line in lines) {
CGContextMoveToPoint(context, line.from.x, line.from.y);
CGContextAddLineToPoint(context, line.to.x, line.to.y);
CGContextStrokePath(context);
}
}
If you do it this way (without OpenGL), there is no need to flip the y axis.
isPointTransparent:. , .