[ad_1]
I have never discovered any documentation on it. I do know you may dismiss keyboard utilizing .keyboardDismissMode on TabliewView and different UIViews however how would you do this with TextEditor() in SwiftUI? I’ve a swipe gesture characteristic proper now however that does not work when the textual content editor will get lengthy and has to scroll as a result of which it doesnt acknowledge gestures anymore.
code:
VStack{
TextEditor(textual content: $newNote)
}
.gesture(DragGesture(minimumDistance: 20, coordinateSpace: .international)
.onEnded({ worth in
if worth.translation.width < 0 {
// left
}
if worth.translation.width > 0 {
self.presentationMode.wrappedValue.dismiss()
hideKeyboard()
self.navigationBarBackButtonHidden = false
}
if worth.translation.top < 0 {
}
if worth.translation.top > 0 {
hideKeyboard()
self.navigationBarBackButtonHidden = false
}
}
))
extension View {
func hideKeyboard() {
let resign = #selector(UIResponder.resignFirstResponder)
UIApplication.shared.sendAction(resign, to: nil, from: nil, for: nil)}
}
[ad_2]
