मुझे आपकी समस्या समझा है। कृपया बेलो कोड देखें। यह आपके लिए पूर्ण उपयोग करेगा।
-(void)intializeDrawImage
{
drawImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 320, 320)];
[drawImage setBackgroundColor:[UIColor purpleColor]];
[drawImage setUserInteractionEnabled:YES];
[self.view addSubview:drawImage];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:drawImage];
startPoint = p;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesMoved");
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:drawImage];
[self drawLineFrom:startPoint endPoint:p];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesEnded:touches withEvent:event];
}
-(void)drawLineFrom:(CGPoint)from endPoint:(CGPoint)to
{
drawImage.image = [UIImage imageNamed:@""];
UIGraphicsBeginImageContext(drawImage.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
[[UIColor greenColor] set];
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0f);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), from.x, from.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), to.x , to.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
आप एप्पल से, [GLPaint] (http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.html) डेमो आवेदन पर एक नज़र रखना चाहिए। यह आपको OpenGL ES का उपयोग करके एकल उंगली चित्रकला की मूल बातें सिखाएगा। – Macmade
UIBezierpath आज़माएं। यह ट्यूटोरियल आपके लिए सहायक हो सकता है। http://soulwithmobiletechnology.blogspot.in/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html –
एक और अच्छा उदाहरण यहां पाया जा सकता है - यह नियंत्रक हस्ताक्षर के इनपुट के लिए प्रदान करता है और एक छवि देता है। इसके अलावा एक कामकाजी उदाहरण प्रदान किया गया है: https://github.com/bunchjesse/JBSignatureController –