As of beta 5, the following doesn't work:
var body: some View {
NavigationView {
Text("Hello")
.navigationBarTitle(Text("My App"))
}
.background(Rectangle()
.foregroundColor(.blue))
}
Neither does just using the background modifier:
var body: some View {
NavigationView {
Text("Hello")
.navigationBarTitle(Text("My App"))
}
.background(Color.blue)
}
Is this a bug, or is there an undocumented way to change the background color from the default white?
Just to be comprehensive, i've also tried setting the univeral appearance on UIView and UILabel:
UIView.appearance().backgroundColor = UIColor.green
UILabel.appearance().backgroundColor = UIColor.red
This does change the background color, but... the Text protocol doesn't seem to respond to UILabel, so the background of any Text contained within the NavigationView remains green (the UIView.appearance color).
If there's no possible way to change the NavigationView background color in the beta, that's ok. I just want to know if I should stop searching for answers or not. Or if there is an answer I'd like to know it 🙂