Extending UIColor to Support Custom Styling
summary
Slides and playground show concrete code that extends UIColor with methods to extract HSB brightness, compute WCAG contrast ratios, and compute the adjusted brightness needed to hit a minimum contrast ratio of 7. Code includes a convenience that returns a new UIColor with adjusted brightness so foregrounds meet accessibility, and notes using iOS 13 dynamic colors and resolvedColor(with:) when converting to CGColor. Tests show low-contrast cases raised to the target ratio.
AI-written summary · about
chapters (24)
- 0:00Start
- 2:23Overview
- 3:11Definition of What a Color Is
- 4:34Color Space
- 5:04Hsv Color Space
- 5:36Saturation
- 6:34Brightness
- 7:45Hsv Color Space
- 8:50Contrast
- 9:18Wcag Standards
- 10:05Contrast Ratio
- 10:26Custom Coloring
- 10:57Examples
- 11:52Dark Mode
- 13:03High Contrast Mode
- 13:35Dynamic Semantic Colors
- 13:53Label
- 14:16Create Custom Dynamic Colors
- 14:46Custom Imagery
- 17:14Color Collisions and How To Handle Them Client-Side
- 17:47Predefined Palette
- 19:41Calculate the Contrast Ratio
- 22:55Recap
- 23:32Code Examples
related talks
16mColor Contrast for Accessibility
28mBuilding the Dark Mode of Your Dreams with Color Science
06mDesign Accessibly: Color Contrast Tips and Tools
28mAccessible by Law! Generating Colors with JS and CSS Custom Properties
41mExploring Colormaps and UI Styles for Data and Information Visualization
19mWhen colour theory meets technology
26mThe World Isn't Black and White, It's RGB
49mInclusive Color: from Photons and Physiology to Psychology and Philosophy
