Method 1: use ZStack
struct BackgroundView: View {
@EnvironmentObject var home: HomeGlobal
var body: some View {
ZStack(alignment: .top) {
Color.orange
.edgesIgnoringSafeArea(.all)
.navigationBarTitle("Back")
.navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(self.home.hiddenBar)
.onAppear {
self.home.hiddenBar = true
}
Text("goood")
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
}
}
}
Method 2: use .background
view modifier
struct BackgroundView: View {
@EnvironmentObject var home: HomeGlobal
var body: some View {
Text("goood")
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color.orange
.edgesIgnoringSafeArea(.all)
)
.navigationBarTitle("Back", displayMode: .inline)
.navigationBarHidden(self.home.hiddenBar)
.onAppear {
self.home.hiddenBar = true
}
}
}