我试图"颜色"在我的UIImageView中。我每次调用此函数时都想绘制一个POINT。
UIGraphicsBeginImageContext(self.sheetTest.frame.size);
[self.sheetTest.image drawInRect:CGRectMake(0, 0, self.sheetTest.frame.size.width, self.sheetTest.frame.size.height)];
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), _lastPoint.x, _lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 30.0 );
CGFloat* components = CGColorGetComponents([UIColor redColor].CGColor);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), components[0], components[1], components[2], 1);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.sheetTest.image = UIGraphicsGetImageFromCurrentImageContext();
[self.sheetTest setAlpha: .6];
UIGraphicsEndImageContext();
ERROR MSG
2017-11-19 15:16:54.192104-0700 slate[5853:2107089] [Unknown process name] CGContextMoveToPoint: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192129-0700 slate[5853:2107089] [Unknown process name] CGContextAddLineToPoint: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192213-0700 slate[5853:2107089] [Unknown process name] CGContextSetLineCap: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192237-0700 slate[5853:2107089] [Unknown process name] CGContextSetLineWidth: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192262-0700 slate[5853:2107089] [Unknown process name] CGContextSetRGBStrokeColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192328-0700 slate[5853:2107089] [Unknown process name] CGContextSetBlendMode: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-11-19 15:16:54.192352-0700 slate[5853:2107089] [Unknown process name] CGContextDrawPath: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
我对不同的ImageView使用类似的代码,它适用于此。但不是我的另一个。有什么想法吗?