小编sna*_*ewa的帖子

UIView drawRect:当你画一条线时,矩形区域将被清除,因此上一张图画消失了

很难说我上传图片来显示我的问题: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)

drawing uiview cgcontext drawrect

0
推荐指数
1
解决办法
9609
查看次数

标签 统计

cgcontext ×1

drawing ×1

drawrect ×1

uiview ×1