Skip to main content

How to adjust the accent color of a view

About 2 minSwiftSwiftUIArticle(s)bloghackingwithswift.comcrashcourseswiftswiftuixcodeappstore

How to adjust the accent color of a view 관련

SwiftUI by Example

Back to Home

How to adjust the accent color of a view | SwiftUI by Example

How to adjust the accent color of a view

Updated for Xcode 15

iOS uses tint colors to give apps a coordinated theme, and the same functionality is available in SwiftUI under the name accent colors. Just like in UIKit, when you set the accent color of one view it affects all those inside it, so if you set the access color of your top-level control then everything gets colored.

For example, this creates a button inside a VStack, then gives it an orange accent color:

VStack {
    Button("Press Here") {
        print("Button pressed!")
    }
}
.accentColor(.orange)

Download this as an Xcode projectopen in new window

The text “Press Here” in orange.
The text “Press Here” in orange.
Similar solutions…
How to dynamically adjust the color of an SF Symbol | SwiftUI by Example

How to dynamically adjust the color of an SF Symbol
How to adjust List row separator visibility and color | SwiftUI by Example

How to adjust List row separator visibility and color
SwiftUI tips and tricks | SwiftUI by Example

SwiftUI tips and tricks
How to dynamically adjust the appearance of a view based on its size and location | SwiftUI by Example

How to dynamically adjust the appearance of a view based on its size and location
How to adjust the opacity of a view | SwiftUI by Example

How to adjust the opacity of a view

이찬희 (MarkiiimarK)
Never Stop Learning.