Here we can Use ZStack
to set the background of the view. Basically ZStack
adding up the elements Top on it. or we can say as on Z-Axis. Here we can use Color.red
which is bit similar to emptyView hence all other items will be added on the Z-Axis
1. Background Color inside safeArea
![](https://janeshswift.com/wp-content/uploads/2022/09/change-background-color-swiftUI-1-1-1024x497.png)
struct ContentView: View {
var body: some View {
ZStack {
Color.red
}
}
}
1. Background Color cover all screen
![](https://janeshswift.com/wp-content/uploads/2022/09/change-background-color-swiftUI-2-1-1024x510.png)
struct ContentView: View {
var body: some View {
ZStack {
Color.red
.ignoresSafeArea()
Text("Thanks for Posting ")
}
}
}