【发布时间】:2019-11-22 15:11:06
【问题描述】:
我有一个关于图像上的 tapAction 的问题。 TapAction 闭包在不应该发生的剪切区域上被调用。我该怎么办?
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(height: 200, alignment: .center)
.presentation(tapped ? Modal(Image(uiImage: image)) : nil)
.clipped()
.cornerRadius(10)
.border(Color.black, width: 2, cornerRadius: 10)
.tapAction {
self.tapped.toggle()
}
结果如下:
【问题讨论】:
-
只是一个猜测 - 除了可能是一个错误之外,您是否尝试过更改修饰符的顺序?我可以产生影响。查看
Button的可点击区域(是的,它与Image不同):alejandromp.com/blog/2019/06/09/playing-with-swiftui-buttons