Skip to content

A Swift package that adds a modifier .keyboardAware() to SwiftUI views to handle the keyboard appearing.

License

Notifications You must be signed in to change notification settings

ralfebert/KeyboardAwareSwiftUI

Repository files navigation

KeyboardAdaptiveSwiftUI

A Swift package that adds a modifier .keyboardAware() to SwiftUI views to handle the keyboard appearing:

Usage:

struct KeyboardAwareView: View {
    @State var text = "example"

    var body: some View {
        NavigationView {
            ScrollView {
                VStack(alignment: .leading) {
                    ForEach(0 ..< 20) { i in
                        Text("Text \(i):")
                        TextField("Text", text: self.$text)
                            .textFieldStyle(RoundedBorderTextFieldStyle())
                            .padding(.bottom, 10)
                    }
                }
                .padding()
            }
            .keyboardAware()  // <--- the view modifier
            .navigationBarTitle("Keyboard Example")
        }

    }
}

Result:

See also

About

A Swift package that adds a modifier .keyboardAware() to SwiftUI views to handle the keyboard appearing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published