我尝试添加全屏透明按钮:
Button(action: {
// my action
}) {
Rectangle()
.opacity(0)
}但是,如果.opacity()小于0.1,按钮操作将停止工作。如何实现全屏透明按钮?
在iOS 14.3(模拟)、iOS 14.2(iPhone X)、Xcode12.3上测试
发布于 2021-01-17 17:08:37
以下是可能的解决方案。使用Xcode12.1/ iOS 14.1进行测试
struct DemoClearButton: View {
var body: some View {
Color.clear
.contentShape(Rectangle())
.onTapGesture {
print(">> transparent tapped")
}
}
}注意:您可能想要添加.edgesIgnoringSafeArea(.all)来代替使用
https://stackoverflow.com/questions/65758838
复制相似问题