我正在iPad上开发一个图像编辑应用程序。它就像一个函数,您可以在其中将文本写入图像,然后保存它。
用户可以从iPad的照片库中选择一张图片。当照片被选中时,它将导航到另一个显示ImageView、TextField、“测试”按钮和“确认”按钮的视图。
我知道如何对允许用户从照片库中选择图像的部分进行编码,并导航到显示ImageView上所选图像的另一个视图。
因此,我需要帮助如何在图像上显示文本和保存图像(与文本在其中)。
发布于 2011-11-04 02:53:31
有几种方法。最简单的方法就是使用这段代码对超级视图进行快照。
CGRect rect = CGRectMake(<your values>);
UIGraphicsBeginImageContext(rect.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();发布于 2012-01-25 06:15:06
在您的UIImageView对象(其中包含来自图片库的图像)中添加一个标签,当您想要图像上的文本时,这个标签的.set框架。您可以通过以下方式添加它:
[yourUiimageView addSubview: yourLabel];然后将你的图像裁剪如下:
UIGraphicsBeginImageContext(yourUiimageView.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[yourUiimageView.layer renderInContext:ctx];
UIImage *albumThumbImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(albumThumbImage);现在将这些数据保存到文档目录中。此图像将包含带有文本的图像。
https://stackoverflow.com/questions/8004364
复制相似问题