UILabel可以设置多种颜色吗?
引用杰森·可可的话 不可能在 UILabel 中设置多个...但是
该怎么做呢?
有什么想法吗?
是否可以在 UILabel
示例“TEST” 中设置混合颜色 我可以将E设置为红色,另一个设置为白色吗?
Quote from Jason Coco
it not possible to set multiple in UILabel... but
how to do like this?
any idea?
is it possible to set mix color in UILabel
example "TEST"
can i set E to red color and another to white color?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
FontLabel 是 UILabel 的直接替代品,可以将属性字符串作为其文本。这将允许您在单个标签中使用多种颜色和字体。
FontLabel is a drop-in replacement for UILabel that can take an attributed string as its text. That will allow you use multiple colors and fonts in a single label.
TTTAttributedLabel 是 UILabel 的直接替代品,比 FontLabel。您需要做的就是将 NSAttributedString 设置为该标签的文本。
TTTAttributedLabel is a drop-in replacement for UILabel that's a lot more lightweight and simple than other libraries like FontLabel, for instance. All you would need to do is set an NSAttributedString as the text for that label.
不,遗憾的是,这对于 UILabel 来说是不可能的。你可以用谷歌搜索一些替代方案,iPad 将有 NSAttributedString,但使用 UILabel 时整个字符串必须是一种字体/颜色。
Nope, sadly this is not possible with UILabel. You can google some alternatives and the iPad will have NSAttributedString, but with UILabel the entire string has to be one font/color.
这在 iOS 5 中是不可能的,但 iOS 6 支持它。正如您在文档中看到的: https:// developer.apple.com/documentation/uikit/uilabel#//apple_ref/doc/uid/TP40006797
UILabel 在 iOS6 中获得了 attributeText 属性,除了 UILabel 之外,许多其他 UI 元素也使用 NSAttributedText。
This is not possible in iOS 5 but iOS 6 supports it. As you can see in the documentation: https://developer.apple.com/documentation/uikit/uilabel#//apple_ref/doc/uid/TP40006797
UILabel gain the attributedText property with iOS6, next to UILabel a lot of other UI elements use NSAttributedText too.