Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI sheet modal background not working with edgesIgnoreSafeArea(.all) - WHY?

I'm running iOS 13 simulator with a SwiftUI sheet modal - trying to paint the sheet background and ignore safe areas - but there's still white sheet showing. Any ideas on how to do this properly?


    var body: some View {
        VStack(alignment: .center, spacing: 0) {

... redacted ...

 }   // VStack
            .background(Color.gray.edgesIgnoringSafeArea(.all))

iPhone Simulator with sheet modal

See the image (attached)

Any ideas what I'm doing wrong?

like image 809
David Avatar asked Oct 27 '25 17:10

David


1 Answers

Expand top container (VStack in your case) to full sheet area, like

VStack {
    // ... your content
}
.frame(maxWidth: .infinity, maxHeight: .infinity)      // << here !!
.background(Color.gray.edgesIgnoringSafeArea(.all))
like image 149
Asperi Avatar answered Oct 30 '25 12:10

Asperi