Geometry Reader/Size of Child Views

Hi -

Hoping someone can point me to a resource/book chapter that will help me solve an issue I am unable to figure out.

I have an HStack of 30 views embedded in a Scroll View. I’d like to show 3 at a time.

I have tried to use geometry reader to calculate the size of the HStack (divided by 3 etc) and then pass that width along to the parent so that it is just big enough to show 3/30 views at a time.

I am wrapping the child view in the Geometry Reader, but I cannot figure out how to pass that “up” to the parent.

I can hard code the width but that solution is not satisfying.

Thoughts? Is Geometry Reader the right tool for this kind of thing?


Sorry to refer to an external site but seem this article is addressing your issue A guide to the SwiftUI layout system - Part 2 | Swift by Sundell