Contents

center

A guide that marks the horizontal center of the view.

Declaration

static let center: HorizontalAlignment

Discussion

Use this guide to align the centers of views:

[Image]

The following code generates the image above using a VStack:

struct HorizontalAlignmentCenter: View {
    var body: some View {
        VStack(alignment: .center, spacing: 0) {
            Color.red.frame(width: 1)
            Text("Center").font(.title).border(.gray)
            Color.red.frame(width: 1)
        }
    }
}

See Also

Getting guides