9.6 · TextKit 1 and 2, and Text in SwiftUI
Text is the most complicated thing a UI draws: scripts, directions, fonts, wrapping, selection. TextKit is the engine under almost every text view.
Mental model. A text view is a storage (the characters), a layout engine (lines and glyphs) and a container (the shape to fill). Change one of the three, and the others follow.
The text system
TextKit 1 and 2, and how SwiftUI relates.
- How is TextKit structured, how do TextKit 1 and 2 differ, and how do UILabel, UITextView and SwiftUI Text relate?
TextKit separates three roles. The text storage (NSTextStorage, an NSMutableAttributedString) holds the characters and attributes (font, colour, paragraph…
More in Layout, rendering & animation
- 9.1 · Auto Layout, intrinsic size, and when layoutSubviews and draw run
- 9.2 · From layout to the GPU, and the two layer trees
- 9.3 · Offscreen passes, rasterization, blending, shadows and masks
- 9.4 · Implicit and explicit animation, UIView animation, and animators
- 9.5 · Core Graphics, UIBezierPath and draw(_:)
- 9.7 · Frame budgets, ProMotion, hitches and hangs
- 9.8 · Margins, stack views, guides, constraint ownership, the layout cycle and measuring
- 9.9 · Coordinate conversion, 3D transforms and layer contents
- 9.10 · How UIView animation really works, springs, timing and display links
- 9.11 · Transform order, fill rules, text measurement, text containers and bitmaps
- 9.12 · Rectangle containment and moving a point between coordinate spaces