Chapter 23. Text

The high-level text classes are NSString and NSAttributedString. Text can be displayed in various ways:

UILabel
Displays text, possibly consisting of multiple lines; neither scrollable nor editable.
UITextField
Displays a single line of editable text; may have a border, a background image, and overlay views at its right and left end.
UITextView
Displays scrollable text, possibly editable; can use data detectors to display tappable links.
UIWebView
A scrollable view displaying rendered HTML. A good way to show text that includes images and tappable links. Can also display various additional document types, such as PDF, RTF, and .doc. Discussed in Chapter 24.
Drawing

There are three main ways to draw text directly:

Core Graphics
Low-level methods for drawing text (not NSStrings). For drawing in general, see Chapter 15.
NSString and NSAttributedString
At a high level, the UIStringDrawing category on NSString and the NSStringDrawing category on NSAttributedString endow strings with the ability to draw themselves, along with metrics methods for learning the dimensions at which a given string will be drawn. Some examples have appeared already in Chapter 12 and Chapter 20.
Core Text
The underlying low-level technology behind all string drawing on iOS. Also provides access to advanced font typographical features.

Note

An app can include fonts within its bundle; these will be loaded at launch time if the app lists them in its Info.plist under the “Fonts provided ...

Get Programming iOS 6, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.