How to set background color for a view

I have a SwiftUI view. How to set background color to it?


I have tried .background() but it doesn't have any calls I want.


Also, how to set background color to a parent view or screen?


I am trying to do this in Xcode 11 Beta.

It seems to be related on the view. While .background(Color.<name of color>) works on a Text component, it doesn't work this way for NavigationView, which is what I'm trying to find out haha https://forums.developer.apple.com/thread/121539

I've found a solution. You should be able to use a Rectangle with the fill attribute, as detailed here: https://forums.developer.apple.com/message/378296#378296

How to set background color for a view
 
 
Q