Skip to content

Instantly share code, notes, and snippets.

@mattyoung
Created July 23, 2020 17:58
Show Gist options
  • Save mattyoung/9b49b67ed662b8c362009d8ebb4feebe to your computer and use it in GitHub Desktop.
Save mattyoung/9b49b67ed662b8c362009d8ebb4feebe to your computer and use it in GitHub Desktop.
struct KeyboardAvoidance: View {
@State var text = ""
var body: some View {
VStack {
// Only work if something is added below the list
TextField("Enter", text: $text)
List {
ForEach(1...50, id: \.self) {
Text("More \($0)")
}
Text("End of List")
}
// by adding this for keyboard avoidance
// Color.clear
// .frame(width: 0, height: 0)
}
// or add this also cause it to work
// .padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment