UILabel可以设置多种颜色吗?

发布于 2024-08-25 10:49:46 字数 238 浏览 5 评论 0原文

引用杰森·可可的话 不可能在 UILabel 中设置多个...但是

该怎么做呢?

有什么想法吗?

alt text

是否可以在 UILabel

示例“TEST” 中设置混合颜色 我可以将E设置为红色,另一个设置为白色吗?

Quote from Jason Coco
it not possible to set multiple in UILabel... but

how to do like this?

any idea?

alt text

is it possible to set mix color in UILabel

example "TEST"
can i set E to red color and another to white color?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦明 2024-09-01 10:49:46

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.

爱已欠费 2024-09-01 10:49:46

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.

心如荒岛 2024-09-01 10:49:46

不,遗憾的是,这对于 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.

悲歌长辞 2024-09-01 10:49:46

这在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文