我正在实现一个警报视图,警报视图有两个按钮:
Submit
是一个按钮,Cancel
是另一个按钮,但要靠近中心。有没有办法控制按钮的位置?
这是我的实现:
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)
}
}
你们中的任何人都知道如何操纵按钮的分离吗?