Lee

How to hide keyboard when tap out of text field

#SwiftUI
extension View {
  // hide keyboard when tap out of text field area
  func hideKeyboard() {
    UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
  }
}