Apple Rich Text Fundamentals
2 days ago
- #iOS Development
- #Rich Text
- #NSAttributedString
- NSAttributedString is Apple's programmatic data structure for handling rich text, composed of a regular text string and key-value pairs of attributes attached to text ranges.
- Attributes include colors (using NSColor/UIColor), fonts (NSFont/UIFont), paragraph styles (NSParagraphStyle), links, attachments, and various text decorations and effects.
- The API of NSAttributedString can be divided into reading, updating, converting (to formats like HTML or RTF), and drawing functions, enabling manipulation and rendering of styled text.
- Rich text supports advanced features like tab stops, lists, tables, writing direction overrides, and truncation with ellipsis, with system-level support for serialization and clipboard operations.