我正在构建一个简单的应用程序,允许用户拍摄照片,将保存在相册中。因为我预计用户将拍摄大量看起来相似但不相同的对象的图像(例如,房屋中家具的细节),所以我想在图像本身添加一个小的文本标题来描述图像的内容。
现在不用担心用户将如何输入此文本,有没有人能给我一些建议,告诉我如何在用UIImagePickerController拍摄的图像中添加一些文本?
发布于 2011-12-22 20:30:53
代码应该是这样的:
UIGraphicsBeginImageContextWithOptions(sourceImage.size, YES, sourceImage.scale);
[sourceImage drawAtPoint:CGPointZero];
NSString *caption = @"Hello World";
UIFont *captionFont = [UIFont boldSystemFontOfSize:24.0];
[[UIColor whiteColor] setFill]; // or setStroke? I am not sure.
[caption drawAtPoint:CGPointMake(10.0f, 10.0f) withFont:captionFont];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();https://stackoverflow.com/questions/8600913
复制相似问题