Enumeration 列挙

ColorScheme

The possible color schemes, corresponding to the light and dark appearances.

Declaration 宣言

enum ColorScheme

Overview 概要

You receive a color scheme value when you read the colorScheme environment value. The value tells you if a light or dark appearance currently applies to the view. SwiftUI updates the value whenever the appearance changes, and redraws views that depend on the value. For example, the following Text view automatically updates when the user enables Dark Mode:


@Environment(\.colorScheme) private var colorScheme


var body: some View {
    Text(colorScheme == .dark ? "Dark" : "Light")
}

Set a preferred appearance for a particular view hierarchy to override the user’s Dark Mode setting using the preferredColorScheme(_:) view modifier.

Topics 話題

Getting Color Schemes

Creating a Color Scheme

Accessing All Schemes

Comparing Color Schemes

Supporting Types 支援を行う型

Default Implementations 省略時実装

Relationships 関係

Conforms To 次に準拠

See Also 参照

Configuration