Reputation: 330
I read tons of questions about how to make the app ignore the safe area, but when I create a new app then the status bar space is ignored anyway without
.ignoresSafeArea()
Why is that? I don't want it to be ignored!
This is all I have:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack{
Text("Hello, world!")
.padding()
Spacer()
}
.frame(width: 300)
.background(Color.teal)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Upvotes: 3
Views: 7919
Reputation: 297
Use this modifier:
.edgesIgnoringSafeArea(.all)
if you don't want everything you can choose : .top, .bottom, .vertical, .horizontal,...
Upvotes: -4
Reputation: 443
You can do it like so:
VStack {
Color.teal
.overlay {
Text("Hello World!")
}
}
Upvotes: 1
Reputation: 330
Ok I got it, inside a ZStack:
GeometryReader { reader in
Color.white
.frame(height: reader.safeAreaInsets.top, alignment: .top)
.ignoresSafeArea()
}
Upvotes: 1