newWidth = myPic.size.width /rapport;
[myPicdrawInRect: CGRectMake (0,0, newWidth, newHeight)] ;
}
Si ([myDrawingcount]> 0) {
CGContextSetLineWidth (CTX, 5);
for (int i = 0; i
NSArray * thisArray = [myDrawingobjectAtIndex: i];
Si ([thisArray count]> 2) {
flotte thisX = [[thisArray objectAtIndex: 0] floatValue];
flotter 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 *) touche withEvent: (UIEvent *) événement {
[myDrawingaddObject: [[NSMutableArrayalloc] initWithCapacity: 4]];
CGPoint curPoint = [[touches anyObject] locationInView: auto];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.
x]];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.y]];
}
- (void) touchesMoved: (NSSet *) touche withEvent: (UIEvent *) événement {
CGPoint curPoint = [[touches anyObject] locationInView: auto];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.x]];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.
y] ];
[selfsetNeedsDisplay];
}
- (void) touchesEnded: (NSSet *) touche withEvent: (UIEvent *) événement {
CGPoint curPoint = [[touches anyObject] locationInView: auto];
[[myDrawinglastObject] addObject: [NSNumbernumberWithFloat: curPoint.x]];
[[myDrawinglastObject] addObject:[NSNumbernumberWithFloat:curPoint.
y]];
[selfsetNeedsDisplay];
}
-(void)cancelDrawing {
[myDrawingremoveAllObjects];
[selfsetNeedsDisplay];
}
- (void) dealloc {
[superdealloc];
[myPicrelease];
[myDrawingrelease];
}
@end
Every fois que vous touchez l'écran, le - (void) Méthode touchesBegan fait un point dans le tableau de myDrawing et puis l'affiche à travers le -. (void) méthode drawRect
Je rencontre un problème avec le code de dessin dans un de mes applications.
Lorsque je tente de changer la couleur d