I can’t find a solution to change my background color view, I tried a lot of options and nothing works.
I’m trying solutions but the isn’t changing
There is my struct of the code:
struct ContentView: View {
var body: some View {
VStack {
Text("Trying ColorView")
.font(.largeTitle)
.bold()
Button("ColorView") {
}
}
.accentColor(Color.black)
}
}
3
Answers
You change a background color with the background modifier.
If you want to change the background color of the whole view, you should create a ZStack that spans the whole view with a background modifier.
First of all you have already mistakes in your posted code above, your XCode should normally tell you that.
Which view you want to change..?
This might be a solution… You can change it like you need it.
You can simply use Color("Green") to change the color. Here’s a sample.