我试图画一条线。
我写了如下代码。
UIColor *currentColor = [UIColor blackColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, currentColor.CGColor);
CGContextMoveToPoint(context, startingPoint.x, startingPoint.y);
CGContextAddLineToPoint(context,endingPoint.x , endingPoint.y);
CGContextStrokePath(context);
但这显示异常如下
Sat Aug 21 10:47:20 AAA-rrr-Mac-mini.local Test[2147] <Error>: CGContextSetLineWidth: invalid context 0x0
Sat Aug 21 10:47:20 AAA-rrr-Mac-mini.local Test[2147] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0
Sat Aug 21 10:47:20 AAA-rrr-Mac-mini.local Test[2147] <Error>: CGContextMoveToPoint: invalid context 0x0
Sat Aug 21 10:47:20 AAA-rrr-Mac-mini.local Test[2147] <Error>: CGContextAddLineToPoint: invalid context 0x0
Sat Aug 21 10:47:20 AAA-rrr-Mac-mini.local Test[2147] <Error>: CGContextDrawPath: invalid context 0x0