问题
Our requirement is to show some text bold and some text as normal style in a label.
e.g. ABC 002
(there is not space between ABC and 002)
There are lots of instances of such labels on a single view, so using UIWebView is not preferred.
Is it possible using the UILabel? If no, then what are the alternatives?
回答1:
Using normal UILabel
dont think this is possible.
Check out this replacement for UILabel TTTAttributedLabel.
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?
Another way is to use 2 UILabels
and position them correctly relative to each other Check out this topic from a previous Stack Overflow.
回答2:
For making the such labels you might have to use TTStyledTextLabel of Three20 libraries, which allows different styles on the same object of text.
回答3:
you can achieve that requirement using TTStyledTextLabel of three20 library
来源:https://stackoverflow.com/questions/9696097/formatted-text-in-uilabel-on-iphone