24 lines
572 B
Swift
24 lines
572 B
Swift
//
|
|
// HideKeyboard.swift
|
|
//
|
|
//
|
|
// Created by Antonio García on 6/5/21.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
// from: https://www.hackingwithswift.com/quick-start/swiftui/how-to-dismiss-the-keyboard-for-a-textfield
|
|
#if canImport(UIKit)
|
|
extension View {
|
|
func hideKeyboard() {
|
|
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
|
}
|
|
}
|
|
|
|
extension ViewModifier {
|
|
func hideKeyboard() {
|
|
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
|
}
|
|
}
|
|
|
|
#endif
|