很难说我上传图片来显示我的问题:http://i42.tinypic.com/2eezamo.jpg
基本上在drawRect中,我将从touchesMoved中绘制线条作为手指触摸,我将调用"needsDisplayInRect"进行重绘.但是我发现第一行已经完成,第二行将清除rect部分,因此一些previouse绘图已经消失.
这是我的实现:
enter code here
-(void) drawRect:(CGRect)rect{
//[super drawRect: rect];
CGContextRef context = UIGraphicsGetCurrentContext();
[self drawSquiggle:squiggle at:rect inContext:context];
}
- (void)drawSquiggle:(Squiggle *)squiggle at:(CGRect) rect inContext:(CGContextRef)context
{
CGContextSetBlendMode(context, kCGBlendModeMultiply);
UIColor *squiggleColor = squiggle.strokeColor; // get squiggle's color
CGColorRef colorRef = [squiggleColor CGColor]; // get the CGColor
CGContextSetStrokeColorWithColor(context, colorRef);
NSMutableArray *points = [squiggle points]; // get points from squiggle
// retrieve the NSValue object and store the value in firstPoint
CGPoint firstPoint; // declare a CGPoint
[[points objectAtIndex:0] …Run Code Online (Sandbox Code Playgroud)