我想打印 <#code#> 块中点击点的位置(x,y 坐标)以及视图的尺寸。
struct ContentView: View {
var body: some View {
self.onTapGesture {
<#code#>
}
}
}
Run Code Online (Sandbox Code Playgroud)
添加DragGesture
到minimumDistance: 0
你的身体,例如:
var body: some View {
VStack
{
}
.frame(
minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity,
alignment: .topLeading
)
.background(Color.red)
.gesture(DragGesture(minimumDistance: 0).onEnded({ (value) in
print(value.location)
}))
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1353 次 |
最近记录: |