I have a view with a class called “drawingViewController”, and I have the drawRect method:
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, 0.0f, 0.0f);
CGContextAddLineToPoint(context, 100.0f, 100.0f);
CGContextStrokePath(context);
}
But I wanna to define some other drawing method, but it did’t work, how can I do so apart from calling drawRect method? thz in advance.
Why do you want another method? This is the one that gets called by the framework when the client area needs drawing or redrawing.
Just to be clear, you never call
drawRect:yourself. You callsetNeedsDisplay:andsetNeedsDisplayInRect:.