Skip to content

Instantly share code, notes, and snippets.

@mrbodich
Created January 24, 2022 08:47
Show Gist options
  • Save mrbodich/725ccded5b6ed7c4e7e29cf62610ff69 to your computer and use it in GitHub Desktop.
Save mrbodich/725ccded5b6ed7c4e7e29cf62610ff69 to your computer and use it in GitHub Desktop.
Background with gesture brakes Button tap
struct ButtonTest: View {
var body: some View {
ScrollView {
VStack {
Button(action: {}) {
Text("Tap me...")
.frame(height: 30)
.padding(.horizontal, 50)
.foregroundColor(.white)
.lineLimit(1)
}
.background(Color.black)
.clipShape(Capsule())
.contentShape(Rectangle())
}
.frame(maxWidth: .infinity)
.frame(height: 200)
.background( //Commented background fix button tap zones
Color.yellow
.onTapGesture {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
)
}
}
}
#if DEBUG
struct ButtonTest_Preview: PreviewProvider {
static var previews: some View {
ButtonTest()
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment