作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个简单的应用程序,允许用户拍摄将保存在相册中的照片。因为我预计用户会拍摄很多看起来相似但不相同的物体的图像(例如,房子里家具的细节),我想在图像本身上添加一个小文字标题来描述图片的内容。
目前不担心用户将如何输入此文本,任何人都可以给我一些关于如何向使用 UIImagePickerController 拍摄的图像添加一些文本的建议吗?
最佳答案
代码应该是这样的:
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();
关于iOS 5 : adding a caption to a camera image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8600913/
我是一名优秀的程序员,十分优秀!