I’m am new to SwiftUI and running into trouble with getting my stacks in the right order to position a button in the upper right corner.
Here is what I have so far:
import SwiftUI
struct MainMenu: View {
var body: some View {
ZStack {
Image("RangeCattle1")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
VStack {
Button("Management") {
}
.buttonStyle(.borderedProminent)
.buttonBorderShape(.capsule)
.tint(.red)
Button("Calculator") {
}
.buttonStyle(.borderedProminent)
.buttonBorderShape(.capsule)
.tint(.red)
}
Spacer()
.font(.title)
}
}
}
#Preview {
MainMenu()
}
I have tried adding an Hstack inside the Z but it only positions it behind the existing buttons or if I add a spacer it pushes it to the left.
Any suggestions? I would like it to be in the upper right hand corner with the existing buttons where they are at.