Hi, this is my code :
Thanks for showing your code, but maybe my words were not well representing what I wanted.
But anyway, if you want some changeable color set, why don't you make it an environment object?
Code Block import SwiftUI |
|
struct ContentView: View { |
@EnvironmentObject var colorManager: ColorManager |
var body: some View { |
Text("Hello, world!") |
.padding() |
//↓ Apply the changeable color |
.background(colorManager.spotifyGreen) |
} |
} |
|
class ColorManager: ObservableObject { |
@Published var spotifyGreen = Color("SpotifyGreen") |
//... |
} |
|
struct ContentView_Previews: PreviewProvider { |
static var previews: some View { |
ContentView() |
.environmentObject(ColorManager()) |
} |
} |