I have a simple search list:
struct ContentView: View {
@State var text:String = ""
var items = 1...100
var body: some View {
VStack {
List {
TextField("Search", text: $text)
Section{
ForEach(items.filter({"\($0)".contains(text)}),id: \.self){(i) in
Text("option \(i)")
}
}
}
}
}
}
How can I make the keyboard close when scrolling for more than 2 cells/few points?
If you are using a ScrollView
(probably also with a List
but I haven't confirmed it), you could use the UIScrollView
appearance
, this will affect all ScrollViews though.
UIScrollView.appearance().keyboardDismissMode = .onDrag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With