drawRectを使用しないと、多くの人がコンテキストエラーを受け取ると聞きました
今私はこれを持っています:
- (void)drawRect:(CGRect)rect {
NSLog(@"drawRect: Starts");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetLineWidth(context, 3.0);
CGContextMoveToPoint(context, lineStart.x, lineStart.y);
CGContextAddLineToPoint(context, lineEnd.x, lineEnd.y);
CGContextStrokePath(context);
}
エラー:
<Error>: CGContextSetRGBStrokeColor: invalid context
これは以前のプログラムで機能していましたが、今回のプログラムでは機能しませんでした。違い:このUIViewを呼び出すViewControllerがあります。
-(void)createLine:(CGPoint)start:(CGPoint)end {
NSLog(@"createLine: Starts");
lineEnd = start;
lineStart = end;
self = [super initWithFrame:drawRect:CGRectMake(fmin(lineStart.x, lineEnd.x), fmin(lineStart.y, lineEnd.y), fabs(lineStart.x - lineEnd.x), fabs(lineStart.y - lineEnd.y))];
}
これが私の最初の質問です。ここにどれだけの情報コードを入れるべきかわからないので、簡単に説明してください。