27.6 ZStack Custom Alignment
By default, the child views of a ZStack are overlaid on top of each other and center aligned. The following figure shows three shape views (circle, square and capsule) stacked on top of each other in a ZStack and center aligned:
Figure 27-16
Using the standard alignment types, the alignment of all the embedded views can be changed. In Figure 27-17 for example, the ZStack has .leading alignment configured:
Figure 27-17
To perform more advanced alignment layouts, where each view within the stack has its own alignment, both horizontal and vertical custom alignments must be combined into a single custom alignment, for example:
extension HorizontalAlignment {
enum MyHorizontal: AlignmentID {
static func defaultValue(in d: ViewDimensions) -> CGFloat
{ d...