Color

#color #colorpalette #gradient #lineargradient

Overview

Changing the Color Scheme

.environment(.colorScheme, .dark)

Changing the Toolbar Color Scheme

.toolbarColorScheme(.dark, for: .navigationBar)

Sources

Detecting the Color Chema

struct ContentView: View {
    @Environment(\.colorScheme) var colorScheme

    var body: some View {
        Text(colorScheme == .dark ? "In dark mode" : "In light mode")
    }
}

Sources

Adding ternary conditional into the color code

.foregroundColor(number > rating ? offColor : onColor)

See also: Conditionals / Ternary Conditional Operator

Color Palette

Frosted Glass: .ultraThinMaterial

Translucent Black: .black.opactity((0.75))

.backgroundColor

.foregroundColor

.foregroundColor vs .foregroundStyle

LinearGradient()

Sample Codes

Sources

Videos

Articles / Documents

Last updated