Updated for Xcode 14.0 beta 1
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 You know StoreKit, but you don’t want to do StoreKit. RevenueCat makes it easy to deploy, manage, and analyze in-app subscriptions on iOS and Android so you can focus on building your app.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.