apple-text-recipes

Use when building common text features or looking up quick recipes — background colors, line numbers, character limits, links, placeholders

Text Recipes Cookbook

Quick, working solutions to the most common "how do I..." questions about Apple text views.

When to Use

  • User asks "how do I [specific text thing]?" and you need a direct answer.
  • You need a working code snippet, not architecture guidance.
  • The question maps to a common text task that doesn't need a full skill.

Quick Index

Find the recipe number below, then see recipes.md for the code.

#RecipeFramework
1Background color behind a paragraphTextKit 1 / TextKit 2
2Line numbers in a text viewTextKit 1
3Character/word limit on inputUITextView delegate
4Text wrapping around an imageNSTextContainer
5Clickable links (not editable)UITextView
6Clickable links (editable)UITextView delegate
7Placeholder text in UITextViewUITextView
8Auto-growing text view (no scroll)Auto Layout
9Highlight search resultsTemporary attributes
10Strikethrough textNSAttributedString
11Letter spacing (tracking/kern)NSAttributedString
12Different line heights per paragraphNSParagraphStyle
13Indent first line of paragraphsNSParagraphStyle
14Bullet/numbered listsNSTextList / manual
15Read-only styled textUITextView
16Detect data (phones, URLs, dates)UITextView
17Custom cursor colorUITextView
18Disable text selectionUITextView
19Programmatically scroll to rangeUITextView
20Get current line numberTextKit 1

Platform Coverage

Recipes show UIKit (iOS) code by default. See the Platform Note at the top of recipes.md for a UIKit → AppKit translation table. Recipes that use only NSTextStorage, NSAttributedString, and NSParagraphStyle work on both platforms without changes.

Quick Decision

  • Need architecture guidance, not a snippet -> /skill apple-text (router)
  • Need paragraph style details (line height, spacing) -> /skill apple-text-line-breaking
  • Need formatting attribute catalog -> /skill apple-text-formatting-ref
  • Need measurement or sizing -> /skill apple-text-measurement

Related Skills and Agents

  • For measurement, exclusion paths, or layout details -> launch textkit-reference agent
  • For paragraph style, line breaking, or formatting attributes -> launch rich-text-reference agent
  • For attachment views (tables, custom views) -> launch rich-text-reference agent
  • For find/replace or editor interaction details -> launch editor-reference agent