SwiftUI safe area not set by default

Hi all,


I am very new to iOS coding. I am experimenting a little bit with views in SwiftUI, and every tutorial I am trying, says that by default, there is a safe area to prevent views landing behind for example the notch. But in following code the text "Hello" is landing behind the notch.

What is it I am doing wrong?


import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack{
            Text("Hello")
            Spacer()
        }.padding()
    }
}


If I remove .padding() at the end, the "Hello" is shown!


I am a little confused! Is it a xcode bug only shown in preview?


thx and kind regards

Ahmet

Accepted Reply

I would update to latest versions:

first

- XCode 11.5

then if needed

- and MacOS 10.15.5

Replies

There is no problem when run on simulator (both with XCode 11.3.1 and 11.5, on Mojave or Catalina.


I tested also in Preview, no problem either. Hello shows, below safe area.


Which version of XCode do you use ?

Which MacOS version ?

On which device-previewer do you preview ?

Hey thanks for trying to help me.


Catalina 10.15.3

XCode 11.4 beta 11N111s

tryed with iphone 11 Pro Max, iphone 11, iphone 11 pro

I would update to latest versions:

first

- XCode 11.5

then if needed

- and MacOS 10.15.5

it was the xcode version I used!

11.5 work fine now for me.


many thanks