- (void)drawRect:(CGRect)rect {
}
- (void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
CGContextRef context = UIGraphicsGetCurrentContext();
UITouch* touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextMoveToPoint(context, point.x, point.y);
CGContextAddLineToPoint(context, point.x + 100, point.y);
CGContextStrokePath(context);
}
And it gives me error
[Unknown process name] CGContextSetStrokeColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. [Unknown process name] CGContextMoveToPoint: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. [Unknown process name] CGContextAddLineToPoint: invalid context 0x0. If you want to see the backtrace, please se CG_CONTEXT_SHOW_BACKTRACE environmental variable. [Unknown process name] CGContextDrawPath: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.