NSTextStore

Each NSLayoutManager has an associated NSTextStorage that acts as a subclass of NSMutableAttributedString. Readers familiar with Core Text or Mac OS X text rendering might be familiar with an attributed string, which is used for storage of stylized text. An NSTextStorage provides an easy-to-interact-with wrapper for easily adding and removing attributes from text.

NSTextStorage can be used setAttributes:range: to add new attributes to a string; for a list of attributes see Table 21.1. Polling the text for currently enabled attributes can be done using attributesAtIndex:effectiveRange:.

Image

Table 21.1 Available Text Attributes

NSLayoutManagerDelegate ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK 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.