Is there an api to let text dynamically change color based on its background?
Asked on 2025-07-29
1 search
Yes, there are APIs that allow text to dynamically change color based on its background to ensure legibility. In the session titled "Build a UIKit app with the new design" from WWDC 2025, it is mentioned that labels automatically become vibrant based on their text color to ensure legibility against a variety of backgrounds. This involves using dynamic colors that adapt to the background, switching between light and dark modes automatically to increase contrast. You can find more details in the session Build a UIKit app with the new design (21:44).

Build a UIKit app with the new design
Update your UIKit app to take full advantage of the new design system. We’ll dive into key changes to tab views, split views, bars, presentations, search, and controls, and show you how to use Liquid Glass in your custom UI. To get the most out of this video, we recommend first watching “Get to know the new design system” for general design guidance.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.

Create custom visual effects with SwiftUI
Discover how to create stunning visual effects in SwiftUI. Learn to build unique scroll effects, rich color treatments, and custom transitions. We’ll also explore advanced graphic effects using Metal shaders and custom text rendering.