Skip to content

Instantly share code, notes, and snippets.

@jbadger3
Created November 10, 2020 19:39
Show Gist options
  • Save jbadger3/9762e8a2e99081797376c4e904cc6bc9 to your computer and use it in GitHub Desktop.
Save jbadger3/9762e8a2e99081797376c4e904cc6bc9 to your computer and use it in GitHub Desktop.
iOS manual keyboard dismissal
struct FormViewFix1: View {
@State var name = ""
@State var yearsExpereince: Int = 0
var body: some View {
NavigationView {
Form {
Section(header: Text("Applicant Info"), content: {
HStack {
Text("Name:")
.fontWeight(.thin)
TextField("", text: $name).background(Color(.systemYellow).opacity(0.3))
}
Picker("Years of experience:",
selection: $yearsExpereince,
content: {
ForEach(0..<11) { years in
Text("\(years)")
}
})
HStack {
Spacer()
Button(action: {
print("Submit button pressed.")
},
label: {
Text("Submit")
})
.padding(3)
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(lineWidth: 1.5)
.foregroundColor( Color(.systemBlue) )
)
Spacer()
}
})
}
.onTapGesture {
self.hideKeyboard()
}
.navigationTitle(Text("Application"))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment