Spacer & Layout Priority
Push views apart with Spacer and control sizing.
Meet Spacer
A Spacer is an invisible view that greedily expands to fill empty space inside a stack, pushing its neighbors apart.
Pushing Views Apart
Drop a Spacer between two views in an HStack and they fly to opposite ends, perfect for a label on the left and a value on the right.
HStack {
Text("Total")
Spacer()
Text("$42")
}All lessons in this course
- Adding Padding Around Views
- Sizing Views with frame
- Backgrounds & Corner Radius
- Spacer & Layout Priority