如何改变IOS UILabel中某个句子的颜色?
假设我的标签中有这样的文本
Lorem ipsum dolor sat amet、consetetur Sadipscing elitr、sed diam nonumy eirmod tempor invidunt ut laboure et dolore magna aliquyamerat, sed diam voluptua。在 vero eos et accusam et justo duo dolores et ea 报应。 Stet clita kasd gubergren,没有海 takimata sainttus est Lorem ipsum dolor 坐在 amet。 Lorem ipsum dolor sat amet, consetetur Sadipscing elitr、sed diam nonumy eirmod tempor invidunt ut labore et Dolore Magna Aliquyam Erat,Sed Diam voluptua。在vero eos et accusam et justo duo dolores et ea rebum。 Stet Clita kasd gubergren,没有海 takimata saintus est Lorem ipsum dolor sat amet。
如何更改第二行开始的句子“At vero eos et...”的颜色?
Suppose I have text like this in a label
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam
et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
takimata sanctus est Lorem ipsum dolor sit amet.
How do I change the colour of the the sentence "At vero eos et..." starting in the second line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不相信 UILabel 类可以做到这一点。然而,在 UIWebView 中使用一些简单的 HTML 来做到这一点并不太难。
让我知道这是否适合您。
I don't believe this is possible with the UILabel class. However, it wouldn't be too hard to do this with some simple HTML in a UIWebView.
Let me know if this works well for you.
您无法使用标准
UILabel
来做到这一点。您要么必须使用多个 UILabel,要么看看 CoreText,它也可以做您想要的事情 - http://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html。You can't do that with a standard
UILabel
. You'd either have to use multipleUILabel
s or take a look at CoreText which would also do what you want - http://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html.