center
A guide that marks the horizontal center of the view.
Declaration
static let center: HorizontalAlignmentDiscussion
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)
}
}
}