Scaling a collection of positioned views to parent (macOS)?

I have a view that lets the user position and size a bunch of subviews. I use .frame() and .position() to accomplish this.

Right now, if the user resizes the window, the views stay where they are, anchored to the top-left corner. What I'd like is for the views to scale as a whole with window, maintaining their relative position, and their aspect ratios.

I can apply .scaleEffect(_:anchor:) to the containing view, and it scales them the way I want, but I'm not sure how to tie it to the window.

My first thought is to use a GeometryReader, but I don't really know what the "original" size would have been in order to compute a scale factor.

How else might I accomplish this?

Why are you trying to manually scale your view depending on the window resizability?

You might want to approach this differently and think about the window resizability and not necessarily the view resizability because SwiftUI automatically handles various layout changes for you.

Instead of .scaleEffect(_:anchor:) you might want to apply a resizability of contentSize

This allows you resize the window based on the size of its content view. Positioning and sizing windows article covers this in more details.

Scaling a collection of positioned views to parent (macOS)?
 
 
Q