Enabling Attributed Text

To handle style requests, you must change a flag that lets your text view work with attributed (in other words, styled) text. Set the allowsEditingTextAttributes property to YES. Upon doing so, several things happen:

Image The text view begins updating its attributedText property. This property enables you to retrieve the text view’s contents as an attributed string.

Image The view begins responding to a series of special UIResponder methods that toggle boldface, italic, and underline for selected text. These methods are detailed in ...

Get The Core iOS Developer’s Cookbook, Fifth 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.