center
A guide that marks the vertical center of the view.
Declaration
static let center: VerticalAlignmentMentioned in
Discussion
Use this guide to align the centers of views:
[Image]
The following code generates the image above using an HStack:
struct VerticalAlignmentCenter: View {
var body: some View {
HStack(alignment: .center, spacing: 0) {
Color.red.frame(height: 1)
Text("Center").font(.title).border(.gray)
Color.red.frame(height: 1)
}
}
}