Home > Software engineering >  How spacing is calculated in HStack
How spacing is calculated in HStack

Time:01-03

In swiftUI when a horizontal array of Circles are made like this

    HStack(spacing : 4){
    Foreach (0..<5){ index in
    
    Circle()
    }
  }

How the spacing value of 4 is applied? is it between the centre of two circles or from their edges?

CodePudding user response:

Building on top of @Asperi's comment... the spacing is applied in the same way it's applied to Text() or Button() views, which is between the frames of the views.

If you click on an element in the preview (this doesn't work when on live preview mode), you can see the frame of an element outlined in blue. The spacing is applied between the edges of the frames of each view.

  • Related