i am new to SwiftUI programming, i've made a view but once the user taps on the textfield the keyboard appears and the entire view pushes up, how do i fix this?
I believe you can use .ignoresSafeArea(.keyboard)
I tested this code in XCode 12.4 and simulator iOS 14.4
struct ContentView: View {
var body: some View {
VStack {
Spacer()
Group {
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
}
HStack{
Spacer()
TextField("INPUT", text: .constant("HERE IS INPUT"))
Spacer()
}
Group {
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
Text("Content")
}
Spacer()
}
.ignoresSafeArea(.keyboard)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With