Reputation: 11317
I have the following code where I am hard coding a UImage on a UIImageView. However I have been asked to modify so that the application allows user to select where on the UIImageView, the UIImage needs to be placed at. I am thinking the user clicks on the screen and the application stores the x,y coordinates where I place the UIImage. I just don't know how to get about doing that.
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
//lets now convert the fax to an image
CGPDFPageRef page = CGPDFDocumentGetPage(document, 1);
UIImage *pageImage = [PDFPageConverter convertPDFPageToImage:page withResolution:144];
UIImage *shieldLogo = [UIImage imageNamed:@"shield_bw.gif"];
UIGraphicsBeginImageContext(pageImage.size);
[pageImage drawInRect:CGRectMake(0, 0, pageImage.size.width, pageImage.size.height)];
[shieldLogo drawInRect:CGRectMake(150, 100, shieldLogo.size.width, shieldLogo.size.height)];
[theSignature drawAtPoint:CGPointMake(200, 100) withFont:[UIFont fontWithName:@"Arial" size:15.0]];
[theSignature2 drawAtPoint:CGPointMake(200, 120) withFont:[UIFont fontWithName:@"Arial" size:15.0]];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[image setImage:resultingImage];
Upvotes: 0
Views: 122
Reputation: 19834
You can also use UIGestureRecognizers in order to alter the UIImage's position.
This is the tutorial that I used to learn how and does a better job than I can here.
Good luck!
Upvotes: 1
Reputation:
Make your subclass responding to touch events using -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
, in which you will modify the frame
property of the image view accordingly.
Upvotes: 1