struct ContentView: View {
@State var text = ""
var body: some View {
Form {
Button(action: {
print("Button pressed")
}) {
Text("Button")
}
}.simultaneousGesture(TapGesture().onEnded( { print("tap") }))
}
}
我需要捕获 Form
上的 Button 操作和点击手势,但只执行 print("tap")
。对于 VStack
来说工作正常,但是 Form
似乎有点特殊。有什么想法吗?
最佳答案
如果您这样做,您将获得按钮点击(还有表单点击)。不知道对你有没有帮助。
@State var text = ""
var body: some View {
Form {
Button(action: {
}) {
Text("Button")
}.onTapGesture {
print("button")
}
}.onTapGesture {
print("form")
} }
}
关于ios - 在 SwiftUI 中的 Form 上捕捉点击手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58433473/