SwiftUI Tell the # of columns assigned in an adaptive LazyVGrid?

Viewed 16

Is there a way to tell the # of columns that are created in a SwiftUI Adaptive Grid? For example the left view with an iPhone 14 Pro has 4 buttons across, while an iPhone 12 mini on the right fits 3 buttons. If I can tell the # of items, then I can tell if there are fewer items than can be displayed on a full screen, then create a LazyHStack for the % resulting leftover items which presents the additional items centered. The smaller iPhone with 3 buttons across shows the effect I'm trying to achieve - which I can do if I fix GridItems to 3 columns. I'd like this to be dynamic so, for example, I can tell I have 3 of 4 buttons across & can put them all in the single, centered LazyHStack of my last column. Thanks for advice! enter image description here

0 Answers
Related