Viewクラスにこれらの2つのメソッドがあります。ビューが初期化されると、drawRectメソッドが常に呼び出されます。しかし、drawLineメソッドを機能させることができません。呼び出されても何もしません。私はcgimagecontextまたはそのようなものを扱うことになっていますか?助けてください!!
- (void)drawRect:(CGRect)rect {
// Drawing code
// Drawing code
CGContextRef contextRef = UIGraphicsGetCurrentContext();
//CGContextSetRGBFillColor(contextRef, 0, 0, 255, 1);
CGContextSetRGBStrokeColor(contextRef, 0, 0, 0, 1);
CGContextSetLineWidth(contextRef, 5.0);
CGContextBeginPath(contextRef);
CGContextMoveToPoint(contextRef, 0, 0);
CGContextAddLineToPoint(contextRef, 320, 480);
CGContextStrokePath(contextRef);
}
-(void)drawLine:(CGPoint)from to:(CGPoint) to {
// Drawing code
CGContextRef contextRef = UIGraphicsGetCurrentContext();
//CGContextSetRGBFillColor(contextRef, 0, 0, 255, 1);
CGContextSetRGBStrokeColor(contextRef, 0, 128, 0, 1);
CGContextSetLineWidth(contextRef, 5.0);
CGContextBeginPath(contextRef);
CGContextMoveToPoint(contextRef, 0, 0);
CGContextAddLineToPoint(contextRef, 320, 50);
CGContextStrokePath(contextRef);
}