skip to content

In SwiftUI, how does a view read the Reduce Motion, Increase Contrast and Differentiate Without Color settings, and what should it change for each?

level: middleimportance: should knowfreq 38%

answer

  1. the system settings live in the environment
  2. read-only, the person decides
  3. fade instead of fly
  4. a glyph beside the color

basics

~20 s

SwiftUI exposes these settings as read-only environment values: accessibilityReduceMotion, colorSchemeContrast and accessibilityDifferentiateWithoutColor. Read them with @Environment and respond: replace large motion with a fade, strengthen borders and contrast, and add shapes or glyphs where color alone carries meaning.

solid answer

~40 s

Each setting is an `EnvironmentValues` property that the view reads with `@Environment`, and SwiftUI redraws dependent views when the person changes it. `accessibilityReduceMotion` is a `Bool`; Apple's documentation says that when it is true the UI should avoid large animations, especially ones that simulate depth, so I swap a bouncy scale or slide for a short opacity change rather than removing feedback. `colorSchemeContrast` is `.standard` or `.increased`; at `.increased` I add borders and use stronger colors. `accessibilityDifferentiateWithoutColor` means color must not be the only signal, so a green "playing" state also gets a glyph. All three are get-only, so a preview cannot fake them with `.environment(_:_:)`: the key path is not writable and the code does not compile. I test them by changing the setting on a device or simulator.

code

swift · 31 lines
swift
import SwiftUI

struct NowPlayingArtwork: View {
    @Environment(\.accessibilityReduceMotion) private var reduceMotion
    @Environment(\.colorSchemeContrast) private var contrast
    @Environment(\.accessibilityDifferentiateWithoutColor) private var differentiateWithoutColor

    let isPlaying: Bool

    var body: some View {
        RoundedRectangle(cornerRadius: 12)
            .fill(.tint)
            .frame(width: 240, height: 240)
            .overlay {
                if contrast == .increased {
                    RoundedRectangle(cornerRadius: 12)
                        .strokeBorder(.primary, lineWidth: 2)
                }
            }
            .overlay(alignment: .bottomTrailing) {
                if differentiateWithoutColor {
                    Image(systemName: isPlaying ? "speaker.wave.2.fill" : "pause.fill")
                        .padding(8)
                        .accessibilityHidden(true)
                }
            }
            .scaleEffect(isPlaying || reduceMotion ? 1 : 0.85)
            .opacity(isPlaying ? 1 : 0.7)
            .animation(reduceMotion ? .easeInOut(duration: 0.2) : .bouncy, value: isPlaying)
    }
}

go deeper

for a junior

Recall the three environment values by name, that they are read-only, and the one-line response to each: fade, contrast, glyph.

for a middle

Explain how @Environment keeps the view in sync when a setting changes, what Apple's documentation asks for under each setting, and why previews cannot fake them.

for a senior

Audit a feature's animations and color-coded states against these settings, choose substitutes that keep feedback, and test on a device or simulator with each setting switched on.

for a principal

Decide whether motion and contrast handling lives in shared animation and color tokens in the design system, so feature teams inherit it rather than each reading the environment.

## Settings as environment values iOS has accessibility display settings that change how a person wants the interface to look and move, beyond VoiceOver and text size. SwiftUI exposes each as a property of **`EnvironmentValues`**, read with `@Environment`: ```swift @Environment(\.accessibilityReduceMotion) private var reduceMotion @Environment(\.colorSchemeContrast) private var contrast @Environment(\.accessibilityDifferentiateWithoutColor) private var differentiateWithoutColor ``` Because they are environment values, SwiftUI re-evaluates the views that read them when the person changes the setting; Apple's `ColorSchemeContrast` documentation says this explicitly. No notification handling is needed. ## What each setting asks for | Environment value | Type | When it is set, Apple's documentation says | |---|---|---| | `accessibilityReduceMotion` | `Bool` | avoid large animations, especially ones that simulate the third dimension | | `colorSchemeContrast` | `ColorSchemeContrast` (`.standard`, `.increased`) | the person chose Increase Contrast; the app can't override the choice | | `accessibilityDifferentiateWithoutColor` | `Bool` | do not convey information using color alone; use shapes or glyphs | | `accessibilityReduceTransparency` | `Bool` | backgrounds should be opaque, not semi-transparent | All four have been available since iOS 13. ## Responding well **Reduce Motion** is about the kind of motion, not about removing feedback. - Replace scaling, sliding, zooming, parallax and bouncing with a short opacity change. - Keep the state change itself, so the person still sees that something happened. - Choose the substitute in one place, for example `.animation(reduceMotion ? .easeInOut(duration: 0.2) : .bouncy, value: isPlaying)` together with a scale that stays at 1 when `reduceMotion` is true. **Increase Contrast** asks for stronger separation. - Add borders or dividers that standard contrast leaves implicit. - Prefer colors with more contrast against their background; a color set in the asset catalog can carry a high-contrast variant that the system selects on its own. **Differentiate Without Color** asks for a second channel. - Add a glyph, a shape or a text label next to a color-coded state, such as a speaker icon on a playing badge. - Do not just change the hue. Any color is still color alone. ## The rest of the family A music app meets three more settings, all read the same way: - **`accessibilityPlayAnimatedImages`** (iOS 17, get-only). Apple's documentation says that when it is false, an image that contains animation should not play automatically, which applies to animated album artwork. - **`accessibilityDimFlashingLights`** (iOS 17, get-only). The documentation ties it to reducing flashing or strobing lights in video content, and suggests playback controls can warn about upcoming content that flashes. - **`legibilityWeight`**, an optional `LegibilityWeight` that is `.bold` when the person has turned on Bold Text. Unlike the others it has a setter, so a preview can set it. Custom drawing that imitates text, such as a hand-drawn track number, may need to follow it. ## Why previews cannot fake them These properties have **getters only**. `environment(_:_:)` takes a `WritableKeyPath`, so this does not compile: ```swift Text("x").environment(\.accessibilityReduceMotion, true) ``` The iOS 27 compiler reports "cannot convert value of type 'KeyPath<EnvironmentValues, Bool>' to expected argument type 'WritableKeyPath<EnvironmentValues, Bool>'". `dynamicTypeSize` is different, because it has a setter, which is why a preview can set a text size but not Reduce Motion. To test, use one of these: 1. Switch the setting on in Settings on a device or simulator and run the screen. 2. While debugging, use Xcode's environment overrides, which belong with the Xcode tooling. 3. Factor the decision into a plain parameter the view takes, so a preview can pass both variants directly. ## Where the logic should live Reading three environment values in every view repeats the same decisions. A view model is the wrong home, because these are presentation concerns. Common choices are a small view modifier that applies "animate with this, or fade", and design-system colors that already include high-contrast variants. Building reusable modifiers and styles is covered in the lesson on reusable SwiftUI components; animation curves and transactions are covered with SwiftUI animation triggers. ## Common mistakes - Treating Reduce Motion as "no animation", which hides state changes. - Changing one shade of green to another under Differentiate Without Color. - Assuming the app can force increased contrast; `colorSchemeContrast` is get-only, and Apple's documentation says the app can't override the person's choice. - Trying to set these values in previews and concluding the code is wrong when it fails to compile.

  • Does Reduce Motion mean the view should not animate at all?
    No. Apple's documentation asks for avoiding large animations, especially ones that simulate the third dimension. Feedback still matters, so keep the state change visible with a quick opacity change or a cross-fade, and drop the scaling, sliding, zooming and bouncing. Removing every animation can make a change easy to miss.
  • Your artwork uses a translucent material behind the controls; which other setting should you read?
    `accessibilityReduceTransparency`. Apple's documentation says that when it is true, backgrounds should not be semi-transparent and should be opaque. Swap the material for a solid background color in that case, which also tends to help contrast.
  • Can the app force increased contrast for its own screens?
    No. Apple's `ColorSchemeContrast` documentation says the person sets it in Settings under Accessibility and that the app can't override the choice; `colorSchemeContrast` is get-only. The app's job is to respond to `.increased`, and colors from an asset catalog can carry a high-contrast variant that the system picks on its own.

  • Overriding accessibilityReduceMotion in a preview with environment(_:_:)
  • Removing all feedback when Reduce Motion is on, not swapping to a fade
  • Showing a playing state with green alone when Differentiate Without Color is on
  • Believing an app can switch increased contrast on for its own screens
  • Polling UIKit for these settings instead of reading the SwiftUI environment