iPhone上的UILabel中的格式化文本 [英] Formatted text in UILabel on iPhone
问题描述
我们的要求是在标签中显示一些文字粗体和一些文字作为正常样式。
Our requirement is to show some text bold and some text as normal style in a label.
ABC 002
(ABC和002之间没有空格)
e.g. ABC 002
(there is not space between ABC and 002)
有很多此类标签的实例一个单一的视图,所以使用UIWebView不是首选。
There are lots of instances of such labels on a single view, so using UIWebView is not preferred.
是否可以使用UILabel? c>使用正常 UILabel
如果没有,那么什么是替代方案?
Is it possible using the UILabel? If no, then what are the alternatives?
推荐答案
不认为这是可能的。
请检查此替换UILabel TTTAttributedLabel 。
Check out this replacement for UILabel TTTAttributedLabel.
另一种方法是使用 CATextLayer 与NSAttributedString!比2 UILabels更轻和更简单。 (iOS 3.2及更高版本),如此处所示 - Bold&在单个UILabel中的非粗体文本?
Another way is to use a CATextLayer with an NSAttributedString ! much lighter and simpler than 2 UILabels. (iOS 3.2 and above) as suggested here - Bold & Non-Bold Text In A Single UILabel?
另一种方法是使用2 UILabels
他们彼此正确相对于此此主题从上一个堆栈溢出。
Another way is to use 2 UILabels
and position them correctly relative to each other Check out this topic from a previous Stack Overflow.
这篇关于iPhone上的UILabel中的格式化文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!