1

I have a view like this:

ScrollView {
    GeometryReader { proxy in
        Color.red
    }
    .frame(height: 0)
    Group {
        Text("B")
            .background(Color.blue)
    }
}

There is a spacing between GeometryReader and the Group. Can we remove that spacing without setting some hardcode padding value? I tried setting frame(height: 0) to that Color.red as well, but that spacing is still there. My goal is to observe the offset change, I followed this tutorial https://www.fivestars.blog/articles/scrollview-offset/, but I don't know why we need to put .padding(.top, -8).

enter image description here

1
  • 1
    ScrollView { VStack(spacing: 0) { } } Commented Oct 19, 2022 at 8:59

1 Answer 1

1

You can use a VStack to customize the spacing:

ScrollView { 
    VStack(spacing: 0) {
        ... 
    } 
}
Sign up to request clarification or add additional context in comments.

Comments

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.