Skip to content

Instantly share code, notes, and snippets.

@SlappyAUS
Last active November 18, 2020 08:05
Show Gist options
  • Select an option

  • Save SlappyAUS/70353b764d2079bf367deb32c88fc19d to your computer and use it in GitHub Desktop.

Select an option

Save SlappyAUS/70353b764d2079bf367deb32c88fc19d to your computer and use it in GitHub Desktop.
Hide Keyboard #swift #swiftui #ui
// Add to View Struct
@State private var editing = false
// TextField Definition
TextField("", text: dailyIntakeGoalString) { (change) in
self.editing = true
} onCommit: {}
// Attach to Parent View
.gesture(TapGesture().onEnded { _ in
KeyboardUtils.endEditing()
self.editing = false
}, including: self.editing ? .all : .subviews)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment