I have a TextField in my iOS app, and it is positioned such that I don't want it to move when the keyboard appears. However, the view is autoresizing when the keyboard appears. Is there a way to prevent this?
import SwiftUI
struct test: View {
@State var text: String = ""
var body: some View {
TextField("Type", text: self.$text)
}
}
You can use a modifier to tell a certain view to ignore specific or all iOS safe areas. Apply the following .ignoresSafeArea(.keyboard)
to the parent view, and it will not resize when the keyboard is open.