VStack{
Text("点击")
}.frame(width: 200, height: 200)
// .background(Color.purple) //加上颜色可以让点击区域生效
.contentShape(Rectangle()) //没有颜色的情况用contentShape扩大点击响应区域
.onTapGesture {
print("tap")
}
网友评论