Group Group Group Group Group Group Group Group Group

Custom Alignment | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/6849561-layout-in-ios/lessons/5

Why isn’t the end result for the three HStacks (after implementation of customCenter) actually centered in the center of the original VStack? Wouldn’t the default “center” actually really be in the true center of that VStack instead of off to the right a bit?

1 Like

Great question!

The end result is centered. It just doesn’t fit within the hard-coded frame of the VStack.

And if you’re questioning why the bottom Text isn’t in the center, check out the beginning of the previous video.

I do see that the three HStacks are centered relative to each other along the newly defined customCenters for the first two and the default center for the third stack , but I don’t understand how SwiftUI decides where to place the ENTIRE resulting VStack on the screen. Does it try to maximize the total amount of image that would have been within the initial VStack box?