Appendix C: Accessibility Checklist

Shader effects are often pure decoration: motion, glow, distortion, color shifts. Several iOS accessibility settings exist for exactly those things, and SwiftUI exposes each of them as an environment value. A shader can't read them itself, so the pattern throughout this appendix is the same: read the setting in Swift, then either pass it to the shader as an argument or swap in a calmer effect.

Settings to check

Each of these is an EnvironmentValues property you read with @Environment(\.name):

  • accessibilityReduceMotion (Settings › Accessibility › Motion › Reduce Motion): stop or shrink movement, parallax, zooming and wobble.
  • accessibilityReduceTransparency (Display & Text Size › Reduce Transparency): make frosted, glassy or translucent effects more opaque.
  • colorSchemeContrast (Display & Text Size › Increase Contrast): .increased when the user wants stronger contrast. Use harder edges and stronger colors.
  • accessibilityDifferentiateWithoutColor (Display & Text Size › Differentiate Without Color): don't rely on hue alone to carry meaning. Add shape, pattern or text.
  • accessibilityInvertColors: Smart Invert is on. See the section on Smart Invert below.
  • accessibilityDimFlashingLights (Motion › Dim Flashing Lights, iOS 17+): soften or remove flashes and strobing.
  • legibilityWeight (Display & Text Size › Bold Text): .bold means the user finds thin, low-contrast text hard to read. Tone down effects drawn over or behind text, such as distortion, noise and low-contrast glows.

All of these update live. When the user changes a setting, SwiftUI re-renders every view that reads it.

Reduce Motion

Removing the effect

The simplest response is to skip the animated effect when Reduce Motion is on:

struct MotionSafeShader<Effect: ViewModifier>: ViewModifier {
    @Environment(\.accessibilityReduceMotion) private var reduceMotion
    let effect: Effect
    
    func body(content: Content) -> some View {
        if reduceMotion {
            // Effect removed entirely
            content
        } else {
            // Full animated effect
            content.modifier(effect)
        }
    }
}

Keeping the look, removing the motion

Removing the effect also removes its look. Often it's better to keep the effect on screen and only stop it moving. Pause the TimelineView that drives time, and pass a scale factor the shader multiplies every movement by:

struct WaveBackground: View {
    @Environment(\.accessibilityReduceMotion) private var reduceMotion
    @State private var start = Date.now
    
    var body: some View {
        TimelineView(.animation(paused: reduceMotion)) { timeline in
            // Elapsed seconds since the view appeared. Keeps Float precision high.
            let time = Float(timeline.date.timeIntervalSince(start))
            
            Rectangle()
                .visualEffect { [reduceMotion] content, proxy in
                    content.colorEffect(
                        ShaderLibrary.animatedEffect(
                            .float2(proxy.size),
                            .float(time),
                            .float(reduceMotion ? 0 : 1)
                        )
                    )
                }
        }
    }
}
[[ stitchable ]] half4 animatedEffect(
    float2 position,
    half4 color,
    float2 size,
    float time,
    float motionScale  // 0.0 for reduced motion, 1.0 for full
) {
    // Scale all motion by motionScale
    float adjustedTime = time * motionScale;
    float waveAmplitude = 10.0 * motionScale;
    
    // ... build the effect from adjustedTime and waveAmplitude.
    // With motionScale = 0 the effect still draws, but holds still.
    return color;
}

Pass time as seconds since a start date, as above. Date().timeIntervalSinceReferenceDate is around 800 million seconds, and at that size a Float can only represent every 64th second, so an animation driven by it freezes or jumps.

Reduce Transparency

Glass and frosted effects sample whatever is behind them, which makes text on top harder to read. When Reduce Transparency is on, raise the opacity of the glass layer so the background shows through less:

@Environment(\.accessibilityReduceTransparency) private var reduceTransparency

// In body: the shader mixes the blurred background with a solid fill by this amount
.layerEffect(
    ShaderLibrary.frostedGlass(.float(reduceTransparency ? 1.0 : 0.6)),
    maxSampleOffset: CGSize(width: 12, height: 12)
)

Color blindness

Color-safe palettes

Red-green deficiencies are the most common forms of color blindness, so a red/green pair is the riskiest choice for anything that carries meaning. The Okabe-Ito palette was designed to stay distinguishable with the common forms of color blindness:

struct ColorBlindSafePalette {
    // Okabe-Ito palette
    static let universal = [
        Color(red: 230 / 255, green: 159 / 255, blue: 0 / 255),    // Orange
        Color(red: 86 / 255, green: 180 / 255, blue: 233 / 255),   // Sky blue
        Color(red: 0 / 255, green: 158 / 255, blue: 115 / 255),    // Bluish green
        Color(red: 240 / 255, green: 228 / 255, blue: 66 / 255),   // Yellow
        Color(red: 0 / 255, green: 114 / 255, blue: 178 / 255),    // Blue
        Color(red: 213 / 255, green: 94 / 255, blue: 0 / 255),     // Vermillion
        Color(red: 204 / 255, green: 121 / 255, blue: 167 / 255),  // Reddish purple
    ]
}

A safe palette helps, but the stronger rule is that color should never be the only signal. If a shader shows state (a red glow for an error, green for success), pair it with an icon, a label or a change in shape, and always do so when accessibilityDifferentiateWithoutColor is on.

Contrast enhancement shader

This shader pushes each pixel's brightness away from middle gray, then mixes a little of the original color back in:

[[ stitchable ]] half4 enhanceContrast(
    float2 position,
    half4 color,
    float2 size,
    float contrastBoost  // 1.0 to 3.0
) {
    if (color.a == 0.0h) { return color; }
    
    // SwiftUI colors are premultiplied. Divide by alpha to get the real color.
    half3 rgb = color.rgb / color.a;
    
    // Convert to luminance
    float luminance = dot(float3(rgb), float3(0.299, 0.587, 0.114));
    
    // Enhance contrast around middle gray
    float enhanced = (luminance - 0.5) * contrastBoost + 0.5;
    enhanced = saturate(enhanced);
    
    // Preserve some color while boosting contrast
    half3 result = mix(half3(enhanced), rgb, 0.3h);
    
    // Premultiply again before returning
    return half4(result * color.a, color.a);
}

With contrastBoost = 2.0, a pixel with luminance 0.6 becomes (0.6 - 0.5) * 2 + 0.5 = 0.7, and one at 0.4 becomes 0.3. The gap between them doubles from 0.2 to 0.4. saturate clips anything pushed past 0 or 1.

The divide and multiply by alpha matter for semi-transparent pixels. SwiftUI hands the shader premultiplied color: 50% transparent white arrives as half4(0.5, 0.5, 0.5, 0.5), not half4(1, 1, 1, 0.5). Measuring luminance on the premultiplied value would treat that white as mid-gray.

Increase Contrast

Detecting it

struct HighContrastAware: ViewModifier {
    @Environment(\.colorSchemeContrast) private var contrast
    
    func body(content: Content) -> some View {
        content
            .visualEffect { [contrast] view, proxy in
                view.colorEffect(
                    ShaderLibrary.adaptiveEffect(
                        .float2(proxy.size),
                        .float(contrast == .increased ? 2.0 : 1.0)
                    )
                )
            }
    }
}

Shader changes for high contrast

This border shader doubles the border width, switches to black, and replaces the soft edge with a hard one when contrastMode is 1:

[[ stitchable ]] half4 highContrastBorder(
    float2 position,
    half4 color,
    float2 size,
    float borderWidth,   // in points
    float contrastMode   // 0 = normal, 1 = high contrast
) {
    // Distance in points to the nearest edge of the view
    float2 toEdges = min(position, size - position);
    float edgeDistance = min(toEdges.x, toEdges.y);
    
    // Increase border width in high contrast mode
    float adjustedWidth = borderWidth * (1.0 + contrastMode);
    
    // Use pure black in high contrast mode
    half3 borderColor = contrastMode > 0.5
        ? half3(0.0)             // Pure black
        : half3(0.2, 0.3, 0.4);  // Muted blue-gray
    
    // 0 on the border, 1 inside. Sharp edge in high contrast, soft otherwise.
    float inside = contrastMode > 0.5
        ? step(adjustedWidth, edgeDistance)
        : smoothstep(0.0, adjustedWidth, edgeDistance);
    
    // borderColor * color.a keeps the result a valid premultiplied color
    return half4(mix(borderColor * color.a, color.rgb, half(inside)), color.a);
}

min(position, size - position) gives the distance to the left and right edges (x) and to the top and bottom edges (y), whichever is closer on each axis. On a 200 × 100 point view, the pixel at (195, 50) gets min((195, 50), (5, 50)) = (5, 50), so edgeDistance is 5 points: it's 5 points from the right edge. With borderWidth = 4 in high contrast mode, adjustedWidth is 8, step(8, 5) is 0, and the pixel is drawn as border.

Pure black works on light content. If the effect also runs in dark mode, choose the border color from colorScheme too.

Smart Invert

Smart Invert inverts the colors of the interface but is meant to leave photos, video and other media alone, so they don't look like negatives. It relies on the app to say which views are media. If your shader produces an image-like result (a photo filter, a rendered gradient scene), mark it so Smart Invert skips it:

Image("photo")
    .colorEffect(ShaderLibrary.vintage())
    .accessibilityIgnoresInvertColors()

VoiceOver

Labels for effects

VoiceOver can't see what a shader draws. If the effect carries meaning or the user can adjust it, describe it with a label and value, and make it adjustable with swipe up and down:

struct AccessibleShaderView: View {
    @State private var effectIntensity: Float = 0.5
    
    var body: some View {
        Image("photo")
            .visualEffect { [effectIntensity] view, proxy in
                view.layerEffect(
                    ShaderLibrary.artisticBlur(
                        .float2(proxy.size),
                        .float(effectIntensity)
                    ),
                    maxSampleOffset: CGSize(width: 16, height: 16)
                )
            }
            .accessibilityLabel("Photo with artistic blur effect")
            .accessibilityValue("Blur intensity: \(Int(effectIntensity * 100)) percent")
            .accessibilityHint("Swipe up or down to adjust blur intensity")
            .accessibilityAdjustableAction { direction in
                switch direction {
                case .increment:
                    effectIntensity = min(1.0, effectIntensity + 0.1)
                case .decrement:
                    effectIntensity = max(0.0, effectIntensity - 0.1)
                @unknown default:
                    break
                }
            }
    }
}

A blur reads neighboring pixels, so it needs layerEffect (which can sample the layer) rather than colorEffect (which only sees the current pixel's color). maxSampleOffset tells SwiftUI how far from the current pixel the shader may sample, so it can render enough of the layer around the edges.

Purely decorative effects need nothing extra. A background shader behind content should stay invisible to VoiceOver, which is the default for a shape or color with no label.

Testing

Checklist

  • [ ] Reduce Motion on: nothing large moves, and the effect still looks intentional.
  • [ ] Increase Contrast on: borders and text over effects stay clearly readable.
  • [ ] Reduce Transparency on: glass effects become opaque enough to read text on top.
  • [ ] Each color filter (Settings › Accessibility › Display & Text Size › Color Filters): information in the effect survives.
  • [ ] Smart Invert on: photo-like shader output isn't inverted.
  • [ ] Dim Flashing Lights on: no flashes or strobing.
  • [ ] VoiceOver: adjustable effects have a label, value and adjustable action; decorative ones are silent.
  • [ ] Switch Control: interactive effects can be reached and operated.
  • [ ] Touch targets are at least 44 × 44 points.
  • [ ] Text over effects meets 4.5:1 contrast for normal text and 3:1 for large text (WCAG AA).
  • [ ] Display Zoom on: the effect scales with the larger layout.
  • [ ] Nothing flashes more than three times in any one-second period.

While running from Xcode, the Environment Overrides button in the debug bar toggles many of these settings without leaving the app. Accessibility Inspector can audit a running screen for contrast, missing labels and small hit targets.

Automated audits

From Xcode 15 and iOS 17, UI tests can run the same audit as Accessibility Inspector:

func testShaderScreenAccessibility() throws {
    let app = XCUIApplication()
    app.launch()
    
    // Navigate to the screen with the shader effect, then audit it.
    // Fails the test for issues like low contrast, missing labels or small hit regions.
    try app.performAccessibilityAudit()
}

The audit doesn't check motion or flashing, so Reduce Motion and Dim Flashing Lights still need a manual pass.