0

I need to annotate on an image.

Probably a simple solution that I am not able to see at the moment.

I need to introduce a UILabel or UITextView onto an image that is currently displaying on the iPad probably by the TouchesBegan/TouchesMoved/TouchesEnded methods (which is something I tried) and then add some text onto the created UILabel or UITextView. Consequently, I need to embed the added text onto that particular image.

Any ideas?

4

1 回答 1

1

So you will create a custom label, move it around, and when the user is done moving it, you will use:

CGSize size = image.size;
UIGraphicsBeginImageContextWithOptions( size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();

// UIImages and CGImageRefs are flipped
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, size.height);
CGContextConcatCTM(context, flipVertical);

CGContextDrawImage(context, rect, [image CGImage]); // draw the image

// CGContextConcatCTM(context, flipVertical); uncomment if the text is flipped - not sure now

[label.text drawAtPoint:label.frame.origin withFont:label.font];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
于 2012-08-28T11:45:03.760 回答