Chapter 23. Text
Text can be displayed in various ways:
- UILabel
- Displays text, possibly consisting of multiple lines, in a single font and size, with color (and highlighted color), alignment, and wrapping and truncation. Discussed in this chapter.
- UITextField
- Displays a single line of editable text, in a single font and size, with color and alignment; may have a border, may have a background image, and overlay views may appear at its right and left end. Discussed in this chapter; a UITextField is a UIControl subclass, so see also Chapter 25.
- UITextView
- Displays scrollable text, possibly editable, in a single font and size, with color and alignment; can use data detectors to display tappable links. Discussed in this chapter.
- UIWebView
- A scrollable view displaying rendered HTML. Because HTML can express text attribute spans, this is a good way to show text in multiple fonts, sizes, colors, alignments, and so on, and to include images and tappable links. Can also display various additional document types, such as PDF, RTF, and .doc. Discussed in the next chapter.
- Drawing
There are three main ways to draw strings directly:
- Core Graphics
- Low-level methods for drawing text (not NSStrings). For drawing in general, see Chapter 15.
- NSString
-
At a high level, the UIStringDrawing category on NSString endows strings with the ability to draw themselves, along with metrics methods (the
sizeWithFont...
methods) for learning the dimensions at which a given string will be drawn. NSString ...
Get Programming iOS 4 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.