newWidth = myPic.size.width /relación;
[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) {
floto thisX = [[thisArray objectAtIndex: 0] floatValue];
flotar 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 toque la pantalla, el - (void) Método touchesBegan hace un punto en la matriz MyDrawing y luego muestra a través de la -. (void) Método drawRect
Estoy teniendo un problema con el código de dibujo en una de mis aplicaciones.
Cuando trato de cambiar el color del trazo utilizando el método CGContextSetStr