【发布时间】:2014-08-06 00:54:22
【问题描述】:
我正在尝试通过touchesMove: 方法画线。
下面是我的touchesMoved:。
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// context setting
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineWidth(context, 2.0);
CGContextSetRGBStrokeColor(context, 255, 0, 0, 0.5);
CGContextSetBlendMode(context, kCGBlendModeNormal);
// drawing
CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
CGContextStrokePath(context);
CGContextFlush(context);
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
touchesMoved: 被调用;但是屏幕上什么也没有显示。
我错过了什么?
已添加
self 是 UIImageView 的子类。
【问题讨论】:
标签: ios objective-c cgcontext