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

4
  • 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? Commented Jul 2, 2021 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. Commented Jul 2, 2021 at 16:08
  • is your issue resolved? I'm also getting same issue. Commented Jul 14, 2023 at 6:17
  • I'm experiencing the same issue with XCode 15.0.0 and iOS 17.1. @user1877760, have solved it? Commented Nov 2, 2023 at 9:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.