ビューの drawRect メソッドでいくつかのベジエ パスを描画しようとしていますが、無効なコンテキスト エラーが発生し続けます。drawRect が呼び出されたときに常にコンテキストがあると思っていたので、理由がわかりません。何か不足していますか?これは私が持っている完全な実装です:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat pattern[] = {5.0, 3.0};
CGContextSetLineDash(context, 0.0, pattern, 2);
// Set line color to be black
[[UIColor blackColor] setStroke];
//Stroke the bezier path for each plane
for(SEPlaneView *plane in self.planes){
// Set line thickness and termination style
[plane.planeBezier setLineWidth:1.0];
[plane.planeBezier setLineCapStyle:kCGLineCapRound];
[plane.planeBezier stroke];
}
CGContextRelease(context);
}