SwiftUI creates a HStack that can shrink freely (4): Layout custom layout

Insert image description here

Overview

We have completed 3 different solutions to a shrinkable "HStack" in the first 3 blog posts. They are:

  • Use HStack to get the "original taste";
  • Use Align + ZStack to take advantage of maximum maneuverability;
  • Use "magic mirror" to implement subview @ViewBuilder, a more concise multi-syntax constructor;

Although we can finally achieve what we want, the above solutions are more or less "wrong".

Insert image description here

And here, we will finally solve this problem with an almost "flawless" solution!

Guess you like

Origin blog.csdn.net/mydo/article/details/135454838