Post

Replies

Boosts

Views

Activity

Reply to SwiftUI: How to dismiss the keyboard by tap on NavigationLink?
You can create an extension of View with the hideKeyboard like sprykly said. extension View {      func hideKeyboard() {       UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)   } } Then in your view: struct MyViewCell: View { @State var navigate = false var body: some View { ZStack { NavigationLink(destination: DestinyView()), isActive: $navigate) { EmptyView() } .hidden() .buttonStyle(PlainButtonStyle()) VStack { ContentOfView() }.onTapGesture { hideKeyboard() navigate = true } } } } Used in SwiftUI1
Sep ’21