How do I display a NSAttributedString on an iPhone? [duplicate]
I believe I understand how to set NSAttributedString values but how on earth do you actually display them in the interface?
examples: UILabel, UITextView, etc.
Specific instructions would be greatly appreciated/
- Thanks!
you could also create a CATextLayer, which works fine with attributed strings... Just create the layer, and set it's string property...
Have fun... :D
If you don't want to bother with CATextLayer, you should check out TTTAttributedLabel. It's just like UILabel, except that supports NSAttributedStrings (using the same setText: method as UILabel, so you can use it as a drop-in replacement)
In iOS 6 and later you can use attributed strings to display formatted text in text views, text fields, and some other controls. Both AppKit and UIKit also define extensions to the basic attributed string interface that allows you to draw their contents in the current graphic context.
NSAttributedString Reference
The controls you mentioned only work with strings, not attributed strings. The only way to display them is to do a lot of work with Core Text. File a complaint with bugreporter.apple.com to request they flesh this part of UIKit out.
精彩评论