I have a SwiftUI List
with a TextEditor
as the last row. In SwiftUI text fields automatically move up above the keyboard. But unfortunately when the TextEditor is in a List
it doesn't seem to work.
There has been a lot of good solutions for this when using a TextField
Ex:- Move TextField up when the keyboard has appeared in SwiftUI. But none of them seem to work when using TextEditor
.
struct ContentView: View {
@State var items: [String] = ["Apples", "Oranges", "Bananas", "Pears", "Mangos", "Grapefruit","Apples", "Oranges", "Bananas", "Pears", "Mangos", "Grapefruit"]
@State private var newItemText : String = ""
var body: some View {
ZStack(alignment: Alignment.bottom) {
List{
ForEach(items, id: \.self) {
Text("\($0)")
}
TextEditor(text: $newItemText)
}
}
}
}