我必须画一条线。我使用下面的代码。我的实际需要是从存在于NSMutableArray
- (void)drawLineGraph:(NSMutableArray *)lineGraphPoints
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextSetLineWidth(context, 1.0f);
CGContextMoveToPoint(context, 10, 10);
CGContextAddLineToPoint(context, 100, 50);
CGContextStrokePath(context);
}
我收到的上下文为零。我收到以下错误
Aug 3 10:46:04 ABC-Mac-mini.local Sample[2077] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0
Aug 3 10:46:04 ABC-Mac-mini.local Sample[2077] <Error>: CGContextSetLineWidth: invalid context 0x0
Aug 3 10:46:04 ABC-Mac-mini.local Sample[2077] <Error>: CGContextMoveToPoint: invalid context 0x0
Aug 3 10:46:04 ABC-Mac-mini.local Sample[2077] <Error>: CGContextAddLineToPoint: invalid context 0x0
Aug 3 10:46:04 ABC-Mac-mini.local Sample[2077] <Error>: CGContextDrawPath: invalid context 0x0
数组lineGraphPoints
有要绘制的点。谁能帮我画一个折线图?