多种颜色的UILabel文字 [英] Multi-colored UILabel text

查看:65
本文介绍了多种颜色的UILabel文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在UILabel中创建多色文本?也就是说,如果我的文字是:

Is is possible to create multi-colored text within a UILabel? I.e, if my text was:

快速的棕色狐狸"

q和b是否为蓝色,其余文本为黑色?

have the q and b in blue with the rest of the text in black?

我感到必须使用UIWebView并以HTML呈现文本来完成此操作.有想法吗?

I get the feeling I'd have to use a UIWebView and render the text in HTML to accomplish this. Thoughts?

推荐答案

您正确地需要使用UIWebView.另外,您可以自己将文本绘制到自定义视图中,但这可能会难以实施.

You are correct that you need to use a UIWebView. Alternatively, you can draw the text yourself into a custom view, but that would probably be a lot more difficult to implement.

如果要自己绘制,请使用

If you are going to draw it yourself, you'll want to use the drawing methods in NSString UIKit Additions along with the -[UIColor set] method etc.

这篇关于多种颜色的UILabel文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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