I'm implementing an alert view and the alert view has two buttons:
Submit
is one button and Cancel
is another button but way to close to the center. There is a way to control the position of the buttons?
Here is my implementation:
var body: some View {
ZStack {
VStack{
Text(text)
TextField("", text: $text, onEditingChanged: {
self.typing = $0
}, onCommit: {
self.text = self.text
})
.textFieldStyle(RoundedBorderTextFieldStyle())
HStack {
Button(action: {
}, label: {
Text("Submit")
})
Button(action: {
}, label: {
Text("Cancel")
})
}
}
.padding()
.frame(width: screenSize.width * 0.7, height: screenSize.height * 0.3)
.background(Color(red: 0.9268686175, green: 0.9416290522, blue: 0.9456014037, opacity: 1))
.clipShape(RoundedRectangle(cornerRadius: 20.0, style: .continuous))
.offset(y: isShown ? 0 : screenSize.height)
.animation(.spring())
.shadow(color: Color(red: 0.8596749902, green: 0.854565084, blue: 0.8636032343, opacity: 1), radius: 6, x: -9, y: -9)
}
}
Any of you knows how can manipulate the separation of the buttons?
You can add spacing in the HStack that the buttons are in:
You can add padding to the buttons:
You can set the frame of the buttons:
You can add a spacer into the HStack: