I'm trying to understand the following very simple view hierarchy:
This is cut off at the top.
If I add a spacer and choose to ignore the bottom safe area, the content is still cut off at the top, and even executes the Spacer!
As soon as I put that into a scrollview, it behaves as expected – full code including previews below:
What is happening here? How to correctly use the full available space, and rather are cut at the bottom than at the top?
Code Block swift struct BugScreenSpacing: View { var body: some View { VStack { Button("This", action:{}) Button("takes", action:{}) Button("a lot", action:{}) Button("of space", action:{}) } } }
This is cut off at the top.
If I add a spacer and choose to ignore the bottom safe area, the content is still cut off at the top, and even executes the Spacer!
Code Block swift struct BugScreenSpacing: View { var body: some View { VStack { Button("This", action:{}) Spacer() Button("takes", action:{}) Button("a lot", action:{}) Button("of space", action:{}) }.edgesIgnoringSafeArea(.bottom) } }
As soon as I put that into a scrollview, it behaves as expected – full code including previews below:
Code Block swift import SwiftUI struct BugScreenSpacing: View { var body: some View { VStack { Button("This", action:{}) Spacer() Button("takes", action:{}) Button("a lot", action:{}) Button("of space", action:{}) }.edgesIgnoringSafeArea(.bottom) } } struct BugScreenSpacing_Previews: PreviewProvider { static var previews: some View { Group { BugScreenSpacing() .previewDevice("Apple Watch Series 6 - 40mm") ScrollView{ BugScreenSpacing() } .previewDevice("Apple Watch Series 6 - 40mm") //Does not depend on device size: BugScreenSpacing() .previewDevice("Apple Watch Series 6 - 44mm") ScrollView{ BugScreenSpacing() } .previewDevice("Apple Watch Series 6 - 44mm") } } }
What is happening here? How to correctly use the full available space, and rather are cut at the bottom than at the top?