Updated for Xcode 14.2
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 project
SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.