In iOS14 SwiftUI
introduced automatic keyboard avoidance. I have form in scrollView that take all screen expect bottom where I have a fixed button.
I want to ignore keyboard avoidance for that button but keep it for scrollView so the textfields move when the keyboard appears.
I tried this code but it didn't work:
struct ContentView: View {
@State var text:String = ""
var body: some View {
VStack {
ScrollView {
TextField("Testing", text: $text)
}
Button("Validate", action: action)
//.ignoresSafeArea(.keyboard) second try
}
//.ignoresSafeArea(.keyboard) first try
}
}
First try: this applies globally, the bottom of the scrollView won't be accessible when keyboard is open.
Second try: this doesn't do anything (Button stays above the keyboard)