Last active
November 18, 2020 08:05
-
-
Save SlappyAUS/70353b764d2079bf367deb32c88fc19d to your computer and use it in GitHub Desktop.
Hide Keyboard #swift #swiftui #ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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