drawRect:
is something that is invoked automatically when you message setNeedsDisplay
or setNeedsDisplayInRect:
on a view. You never call drawRect:
directly.
However you are right in saying that all drawing operations are done within the drawRect:
method. Typical implementation would be,
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
/* Do your drawing on `context` */
}
Since you are using UIBezierPath
s, you will need to maintain an array of bezier paths that you will need to draw and then call setNeedsDisplay
when something changes.
- (void)drawRect:(CGRect)rect {
for ( UIBezierPath * path in bezierPaths ) {
/* set stroke color and fill color for the path */
[path fill];
[path stroke];
}
}
where bezierPaths
is an array of UIBezierPath
s.