Hi st0321,
Since there's no concept like UIAppearance in SwiftUI, I'd suggest an approach of defining your reusable themed views and using those across your project instead of basic SwiftUI views, here's an example featuring a Button themed with orange text:
import SwiftUI
struct MyButton: View {
private let action: () -> Void
private let title: String
init(action: @escaping () -> Void, title: String) {
self.action = action
self.title = title
}
var body: some View {
Button(action: self.action) {
Text(self.title)
.foregroundColor(.orange)
}
}
}
struct MyView: View {
var body: some View {
MyButton(action: {
// your action
}, title: "Hello world")
}
}
I hope this helps!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: