Reputation: 699
I would like to change my background color, but I am using NavigationView and List. That's why the ZStack method doesn't work for me.
This is my Code:
NavigationView {
List {
Text("Some Text")
}
.navigationBarTitle("Test")
}
Upvotes: 0
Views: 342
Reputation: 699
Finally I have found an answer to my problem:
init() {
UITableView.appearance().backgroundColor = UIColor(named: "CustomBackgroundColor")
UITableViewCell.appearance().backgroundColor = UIColor(named: "CustomBackgroundColor")
UITableView.appearance().tableFooterView = UIView()
}
var body: some View {
NavigationView {
List {
Text("Hello")
}
.navigationBarTitle("Test")
}
}
Upvotes: 0
Reputation: 11531
You can use .listRowBackground inside the List.
ZStack{
Color.blue
NavigationView {
ZStack{
Color.red
List {
ZStack{
Color.green
Text("Some Text").background(Color.green).opacity(0.5)
}.listRowBackground(Color.red)
}
}
.navigationBarTitle("Test")
}.padding()
}
Upvotes: 1
Reputation: 326
NavigationView {
List {
Text("Some Text")
}
.navigationBarTitle("Test")
}.colorMultiply(Color.green)
Upvotes: 0