24.7 · Adaptive colour, font fallback and mirrored drawing

Three places where the system adapts to the user and your code has to cooperate: colours that change with appearance and contrast, text in scripts your font does not contain, and layouts and images that mirror.

Mental model. Resolve colours against traits, never cache them; never name system fonts; and know which layout types mirror by themselves.

Adaptation

Dynamic colour, font cascade, mirrored layout and images.

  1. How do dynamic colours work, how do you give a colour dark and high-contrast variants, and when does a colour stop adapting? 24.7.1 · L3
    A UIColor created with a closure (UIColor { traits in … }) or a named colour from an asset catalog is a dynamic colour: it holds several values and picks one…
  2. What happens when text contains characters the font does not have, and why should you never hard-code system font names? 24.7.2 · L3
    No font covers every script. When a character is missing, Core Text walks a cascade list of fallback fonts and draws that glyph with the first one that has it…
  3. Which layouts and images mirror for right-to-left languages automatically, and what must you handle yourself in custom drawing? 24.7.3 · L3
    The first-pass question covered leading and trailing constraints. The remaining gaps are components that mirror themselves and the things that never do. A…

More in Accessibility & localization