Change background color of view in SwiftUI

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
struct ContentView: View {
    var body: some View {
        ZStack {
            Color.red
        }
    }
}
1. Background Color cover all screen
struct ContentView: View {
    var body: some View {
        ZStack {
            Color.red
                .ignoresSafeArea()
            Text("Thanks for Posting ")
            
        }
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *