Here is my solution as none of the others worked in my case so I thought I would share..
So for the Navigation header bar colour, add an initialiser like this:
struct ContentView: View {
init() {
UINavigationBar.appearance().backgroundColor = .red
}
var body: some View {
NavigationView {
ScrollView {
...
}
}
}
}
And then for editing the ScrollView background color, you can do something like this:
I have done for ListView but you can do it for ScrollView.
struct ListBackgroundColor: ViewModifier {
let color: UIColor
func body(content: Content) -> some View {
content
.onAppear() {
UITableView.appearance().backgroundColor = self.color
//(Optional) Edit colour of cell background
UITableViewCell.appearance().backgroundColor = self.color
}
}
}
extension View {
func listBackgroundColor(color: UIColor) -> some View {
ModifiedContent(content: self, modifier: ListBackgroundColor(color: color))
}
}
UI Example https://i.stack.imgur.com/G5PXt.jpg