5

Since iOS14 I have found that all my TextFields are moving up automatically once the keyboard appears.

I haven't found a way to stop this, have I missed something?

Here is a simple Demo+Code:

Demo:

Code:

import SwiftUI

struct ContentView: View {
    
    @State private var textInput: String = ""
    
    var body: some View {
        TextField("Test", text: $textInput)
    }
}
Kai Zheng
  • 6,640
  • 7
  • 43
  • 66

1 Answers1

7

Here is possible solution for your scenario. Tested with Xcode 12 / iOS 14

demo

var body: some View {
    VStack {
        Spacer()
        TextField("Test", text: $textInput)
        Spacer()
    }
    .ignoresSafeArea(.keyboard, edges: .bottom)
}
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Asperi
  • 228,894
  • 20
  • 464
  • 690