畫實線我有一個關於iOS上如何通過QuartzCore iOS中
石英核心問題當我使用Quartz繪製線條,將出現以下情況,我無法找到原因:
當我繪製的第二行的第一行就會消失
當我繪製第三行第二會消失不見,而第一和第三將顯示 ..
當我畫了2N + 1條線,1,3,5,... 2N-1號線節目,2,4 ,6,8 ... 2N dissappears
看到下面的代碼。我沒有背景和路徑 保存爲我的理解,我覺得應該是這兩種情況一個
- 顯示我畫的所有行
- 顯示我最後繪製的線條和前行應該消失
但是這兩種情況都沒有發生。
- (void)drawInContext:(CGContextRef)context {
// 橡皮擦
//CGContextClearRect(context, CGRectMake(0, 0, 320, 480));
CGContextSetLineWidth(context, 4.0);
CGContextMoveToPoint(context, previousPoint.x, previousPoint.y);
CGContextSetRGBStrokeColor(context, 0, 1.0, 1.0, 1.0);
CGContextAddLineToPoint(context, nextPoint.x,nextPoint.y);
CGContextStrokePath(context);
//NIF_TRACE(@"began : %@ moved : %@", NSStringFromCGPoint(previousPoint),NSStringFromCGPoint(nextPoint));
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
previousPoint = [touch locationInView:self];
nextPoint = [touch locationInView:self];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
previousPoint = nextPoint;
nextPoint = [touch locationInView:self];
[self setNeedsDisplay];
}
我看到使用的NSMutableArray保存它繪製所有UIBezierPaths演示,當查看重繪,它傳送保存在陣列的路徑,恢復他們的drawRect:
UIBezierPath是目標C的包裝,並且它只能在3.2+ 我需要做一些事情讓它在3.0+ 工作,我想它一定是存在一個更好的方法來保存環境和路徑(顏色,路徑,strokeWidths)
任何人有想法?
NO **它的註釋**'// CGContextClearRect(背景下,CGRectMake(0,0,320,480));'這個問題是不存在的。 – aelam