}
if ([myDrawingcount]> 0) {
CGContextSetLineWidth (ctx, 5);
for (int i = 0; i
NSArray * thisArray = [myDrawingobjectAtIndex: i];
if ([thisArray contagem]> 2) {
flutuar thisX = [[thisArray objectAtIndex: 0] floatValue];
flutuar thisY = [[thisArray objectAtIndex: 1] floatValue];
CGContextBeginPath (CTX);
CGContextMoveToPoint (ctx, thisX, thisY);
for (int j = 2; j
thisX = [[thisArray objectAtIndex: j] floatValue];
thisY = [[thisArray objectAtIndex: j + 1] floatValue];
CGContextAddLineToPoint (CTX, thisX, thisY);
}
CGContextStrokePath (CTX);
}
}
}
}
- (void) touchesBegan: (NSSet *) toca withEvent: (UIEvent *) evento {
[myDrawingaddObject: [[NSMutableArrayalloc] initWithCapacity: 4]];
CGPoint curPoint = [[toques anyObject] locationInView: self];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.
x]];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.y]];
}
- (void) touchesMoved: (NSSet *) toca withEvent: (UIEvent *) evento {
CGPoint curPoint = [[toques anyObject] locationInView: self];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.x]];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.
y] ];
[selfsetNeedsDisplay];
}
- (void) touchesEnded: (NSSet *) toca withEvent: (UIEvent *) evento {
CGPoint curPoint = [[toques anyObject] locationInView: self];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.x]];
[[myDrawinglastObject] addObject:[NSNumbernumberWithFloat:curPoint.
y]];
[selfsetNeedsDisplay];
}
-(void)cancelDrawing {
[myDrawingremoveAllObjects];
[selfsetNeedsDisplay];
}
- (void) dealloc {
[superdealloc];
[myPicrelease];
[myDrawingrelease];
}
@end
Every vez que você toca na tela, o - (void) Método touchesBegan faz um ponto na matriz MyDrawing e, em seguida, exibe-lo através do -. (void) método drawRect
Estou tendo um problema com o código de desenho em um dos meus apps.
Quando eu tento mudar a cor do traço usando o método CGContextSetStrokeColorWithColor, todas as linhas que eu havia desenhado anteriormente mudança para essa