All the solutions from this thread did not work for me when the application was in production. It only works during the development process.
More over, I am not sure that adding the UIView.appearance(whenContainedInInstancesOf:) call within the @main app entry initializer is a good practice as swiftUI views call it every time the view redraws.
The trick for me was calling appearance without the parameter whenContainedInInstancesOf of appearance(), on a onAppear() modifier.
It also work only when setting the color this way: UIColor(named: "AccentColor"). Calling UIColor(.accentColor)from SwiftUIColor` does not work.
@main
struct AwesomeApp: App {
var body: some Scene {
WindowGroup {
Group {
ContentView()
}
.onAppear { UIView.appearance().tintColor = UIColor(named: "AccentColor") }
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: