向图像添加文本 [英] Add Text to the Image

查看:136
本文介绍了向图像添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我正在开发一个应用程序,我必须在图像的任何位置(而不是子视图)添加图像上的文本,输出应该是单个图像文件包含原始图像和嵌入其中的文本,任何帮助都会很明显。

Im currently developing an application where i have to add the text over the image at any position in the image(not subview) and the output should be the single image file with the original image and the text embedded in it,any help will be appreciable.

例如:图像上的水印

谢谢
sivasankar

Thanks sivasankar

推荐答案

UIImage *myImage = loadUnwatermarkedImage();
NSString *myWatermarkText = @"Watermark";
UIImage *watermarkedImage = nil;

UIGraphicsBeginImageContext(myImage.size);
[myImage drawAtPoint: CGPointZero];
[myWatermarkText drawAtPoint: CGPointMake(10, 10) withFont: [UIFont systemFontOfSize: 12]];
watermarkedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

完成后, watermarkedImage 将是一个自动释放的水印图像。 loadUnwatermarkedImage()是一个提供原始图像的虚构函数。

Upon completion the watermarkedImage will be an autoreleased watermarked image. loadUnwatermarkedImage() is a fictional function providing an original image.

这篇关于向图像添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆