我正在尝试在我的视图的drawRect方法中绘制一些bezier路径,但我不断收到无效的上下文错误。我不明白为什么,因为我认为在调用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);
}