ios – How you can pin the underside of a VStack to the underside of a ScrollView in SwiftUI?

0
36


Pin VStack to the underside of its mother or father ScrollView

I’ve a ScrollView containing a VStack with some Textual content. I would like the underside of this VStack to be “pinned” to the underside of the ScrollView.

Within the picture beneath, I would like the VStack with a yellow background to increase all the best way beneath. It is not pinned to the underside of the inexperienced ScrollView.

enter image description here

The ScrollView is wrapped in a GeometryReader` and the display’s top is handed to the nested VStack. From what I can see, this measured top doesn’t embrace the underside a part of the display.

struct ContentView: View {
    var physique: some View {
        GeometryReader { gm in
            ScrollView {
                VStack {
                    HStack {
                        Textual content("Title")
                            .font(.largeTitle)
                            .fontWeight(.daring)
                            .padding(.main)

                        Spacer()
                    }

                    Spacer()
                        .body(top: 60)

                    HStack(alignment: .middle) {
                        Textual content("Header Textual content")
                    }
                    .body(top: 60)
                    .body(maxWidth: .infinity)
                    .background(Colour.white)
                    .cornerRadius(6.5)
                    .padding(.horizontal)
                    Spacer()
                        .body(top: 60)

                    // I would like this to occupy all of the remaining house
                    VStack {
                        Textual content("ABC")

                        Textual content("DEF")
                    }
                    .body(maxWidth: .infinity)
                    .body(top: gm.dimension.top)
                    .background(Colour.yellow)
                }
                .body(maxWidth: .infinity, maxHeight: .infinity)
            }
            .body(maxWidth: .infinity, maxHeight: .infinity)
            .background(Colour.inexperienced.ignoresSafeArea())
        }
    }
}