ColorSchemeContrast

The contrast between the app's foreground and background colors.

EnumerationiOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+ColorSchemeContrast in SwiftUI

Declaration

React
type ColorSchemeContrast = SwiftOpaque<'ColorSchemeContrast'>;
Swift
enum ColorSchemeContrast

Overview

You receive a contrast value when you read the EnvironmentValues.colorSchemeContrast environment value. The value tells you if a standard or increased contrast currently applies to the view. SwiftUI updates the value whenever the contrast changes, and redraws views that depend on the value. For example, the following Text view automatically updates when the user enables increased contrast:

@Environment(\.colorSchemeContrast) private var colorSchemeContrast

var body: some View {
    Text(colorSchemeContrast == .standard ? "Standard" : "Increased")
}

The user sets the contrast by selecting the Increase Contrast option in Accessibility > Display in System Preferences on macOS, or Accessibility > Display & Text Size in the Settings app on iOS. Your app can't override the user's choice. For information about using color and contrast in your app, see doc://com.apple.documentation/design/human-interface-guidelines/accessibility#Color-and-effects in the Human Interface Guidelines.

From Apple’s SwiftUI documentation. Code samples there are Swift.

See also

More in Visual effects.