Home > Software design >  Align content to top of sheet instead of middle
Align content to top of sheet instead of middle

Time:08-04

Is there a way with SwiftUI to align content directly to the top of a sheet instead of in the middle?

My sheet is just a simple Text view.

CodePudding user response:

Use a spacer to move it at top, like

VStack {
  Text("Your text")
  Spacer()           // << here !!
}

CodePudding user response:

You can try this way beside Spacer() too:

    VStack {
        Text("Hello World!")
            .frame(maxHeight: .infinity, alignment: .top)
    }

enter image description here

  • Related