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

问题描述

如何将文本转换为图像并在UIImageview中显示。
有谁能知道从文本到图像的转换?

How to Convert Text to Image and show in UIImageview.Can anyone know the conversion from Text to Image?

推荐答案

你可以开始玩这样的事情:

You can start playing around with something like this:

NSString *string = @"Some text";
UIGraphicsBeginImageContext(CGSizeMake(80, 50));
[string drawAtPoint:CGPointMake(10, 20)
           withFont:[UIFont systemFontOfSize:12]];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

result 包含带有文本的UIImage它,你可以将它分配给UIImageView 图像属性。

result contains the UIImage with the text in it, and you can assign it to the UIImageView image property.

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

08-20 09:53
查看更多