I have a TextField near the top of the screen, followed by a spacer and more content below. The TextField moves outside of the screen when the keyboard is opened.
I’ve tried adding .ignoresSafeArea(.keyboard), separating the TextField from the rest of the content into two VStacks nestled in a ZStack, and a few other things found online, but nothing seems to do the trick so far.
Example:
Code to reproduce:
struct ContentView: View {
@State private var text = ""
var body: some View {
VStack {
TextField("Text", text: $text)
.font(.largeTitle.weight(.medium))
.padding()
Spacer()
VStack {
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
}
.padding()
VStack {
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
}
.padding()
}
.ignoresSafeArea(.keyboard)
}
}





