My SwiftUI View is pushed up by the keyboard despite using the .ignoresSafeArea(.keyboard)
modifier:
import SwiftUI
struct PushUpView: View {
@State var random = ""
var body: some View {
ZStack(alignment: .top) {
Color.clear
VStack {
ForEach(0..<25) { id in
Text("Text: \(id)")
}
TextField("Hello, World!", text: $random)
Spacer()
}
}
.ignoresSafeArea(.keyboard)
}
}
Pursuant to the following threads:
- swiftui-in-ios14-keyboard-avoidance-issues
- how-to-prevent-keyboard-from-pushing-up-the-view-in-swiftui
- swiftui-ios14-disable-keyboard-avoidance
I thought that by using Spacer()
, and by putting the keyboard avoid-er on a ZStack
that has a Color.clear
background that takes up all available space I'd be safe.
Alas, the problem persists. What am I doing wrong?