Custom color management

I have created custom colors but I don't know how to save these views in the application so that the colors in background and foreground change according to the custom color change.

How can I do this ?
Please show your code applying the custom color change.
Hi, this is my code :

import SwiftUI
struct ColorManager { // create static variables for custom colors

static let spotifyGreen = Color("SpotifyGreen")
//... add the rest of your colors here}

// Or you can use an extension// this will allow you to just type .spotifyGreen and you wont have to use
ColorManager.spotifyGreenextension Color {
static let spotifyGreen = Color("SpotifyGreen") // ... add the rest of your colors here}

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())
}
}


Custom color management
 
 
Q