将NSString绘制为UIImage [英] Drawing NSString to UIImage

查看:112
本文介绍了将NSString绘制为UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSString对象。
我想将它写入现有的UIImage对象。
UIImage对象已经有一些与之关联的图像。
我想将字符串写入同一图像。
我如何实现它?

I have a NSString object. I want to write it to existing UIImage object. UIImage object already has some image associate with it. I want to write string to same image. How do i achieve it?

推荐答案

编辑:
以下是实现编辑的基本步骤UIImage并在其上写文字。

Following are basic step to achieve to edit an UIImage and write text on it.


  1. 从UIImage获取CGImage。

  2. 渲染CGImage在上下文中。

  3. 在同一个上下文中渲染要写入的文本。

  4. 获取上下文的位图并使其成为CGImage。

  5. 从CGImage获取UIImage ....

  1. Get CGImage from UIImage.
  2. Render CGImage On context.
  3. Render Text you want to write on the same context.
  4. Get Bitmap of context and make CGImage out of that.
  5. Get UIImage from CGImage....

显示文本和标签并显示更容易在图像视图上。
并且答案已经存在。

It would be much easier to show text on and label and show that on image view. And answer for that are already there.

然后将其更新为文件或在屏幕上显示....

Then Update it to file or show it on the screen....

这篇关于将NSString绘制为UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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