I have created a TextField
to get a user name in SwiftUI framework
I have done a code of implementing TextField
in SwiftUI
. and also I have implemented while the user clicks the return button on the keyboard. But I have to resign a keyboard while user tap on BackGround view (
ContentView or non TextField View)
Have to implement Touches began and Touches End
tracking
struct ContentView : View {
@State private var name: String = ""
var body: some View {
VStack{
Text("Good monring \(name)")
TextField($name, placeholder: Text("Name...")) {
UIApplication.shared.keyWindow?.endEditing(true)
}
}
}
}