Contents

firstTextBaseline

A guide that marks the top-most text baseline in a view.

Declaration

static let firstTextBaseline: VerticalAlignment

Mentioned in

Discussion

Use this guide to align with the baseline of the top-most text in a view. The guide aligns with the bottom of a view that contains no text:

[Image]

The following code generates the image above using an HStack:

struct VerticalAlignmentFirstTextBaseline: View {
    var body: some View {
        HStack(alignment: .firstTextBaseline, spacing: 0) {
            Color.red.frame(height: 1)
            Text("First Text Baseline").font(.title).border(.gray)
            Color.red.frame(height: 1)
        }
    }
}

See Also

Getting guides