- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.drawImage];
if (touch.tapCount == 1) {
lastPoint = [touch locationInView:self.drawImage];
} else {
drawImage.image = nil;
}
FirstPoint=currentPoint;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.drawImage];
UIGraphicsBeginImageContext(self.drawImage.frame.size);
CGRect drawRect = CGRectMake(0.0f, 0.0f,
self.drawImage.frame.size.width,
self.drawImage.frame.size.height);
[drawImage.image drawInRect:drawRect];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1.0f);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0f, 0.0f, 0.0f, 1.0f);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1.0f);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// lastPoint = currentPoint;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if (UITouchPhaseEnded) {
CGPoint currentPoint = [touch locationInView:self.drawImage];
endPoint=currentPoint;
}
// [[NSNotificationCenter defaultCenter] postNotificationName:@"metro" object:nil];
}
Рисут "солнышком". Непонятно как реальзовать так, чтобы было как в paint под windows