은 내가 이전에 그것을 사용하고 다음을 사용합니다. 확실히 작동 할 것입니다 : -
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
[drawImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"white" ofType:@"png"]]];
return;
}
lastPoint = [touch locationInView:self.view];
lastPoint.y -= 20;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.drawImage];
currentPoint.y -= 20;
NSLog(@"current Point is x: %d, y: %d",currentPoint.x,currentPoint.y);
UIGraphicsBeginImageContext(self.drawImage.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.drawImage.frame.size.width, self.drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.5, 0.6, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
어머, 귀하의 앱 작성 방법을 알려주시겠습니까? 가서 튜토리얼을보세요. 앱 개발에 대해 자세히 알아보십시오. 시작하는 법을 모르는 경우, 그 일을하기에 충분하지 않은 좋은 징조입니다. – CommunistPancake
http://stackoverflow.com/questions/how-to-ask – Krishnabhadra
가능한 [iOS 오픈 소스 그리기 응용 프로그램 소스 코드] 중복 (http://stackoverflow.com/questions/4121184/ios-open-source-drawing- application-source-code) –