0

I just can't seem to get rid of the ~6 height padding(?) at the top of ScrollView. I've tried setting padding to 0 on both the ScrollView itself and on it's content. I've tried using SwiftUI-Introspect to get at the content insets, but they appear to already be 0 for the top. I could just use offset(y: -6), but I'd like to understand what is causing the padding. Does anyone know?

var body: some View {
    VStack(spacing: 0) {
        Rectangle()
            .frame(width: UIScreen.main.bounds.width, height: 200)
            .foregroundColor(.blue)
        Rectangle()
            .frame(width: UIScreen.main.bounds.width, height: 200)
            .foregroundColor(.red)
        ScrollView {
            Rectangle()
                .frame(width: UIScreen.main.bounds.width, height: 200)
                .foregroundColor(.black)
        }
    }
}

enter image description here

user1877760
  • 263
  • 2
  • 9
  • Have you used the View Debugger in Xcode to see if the space is above the scroll view or above the content within the scroll view? – hayesk Jul 02 '21 at 15:45
  • I am unable to reproduce this. I tested in XCode and there is no space. Restart your XCode and make sure you're testing on a Simulator as well. – xTwisteDx Jul 02 '21 at 16:08
  • is your issue resolved? I'm also getting same issue. – Deepak Singh Jul 14 '23 at 06:17

0 Answers0