Simple solution for keyboard avoiding. View that manages it's bottom constraint constant or frame height to avoid keyboard.
To run the example project, clone the repo, and run
pod install from the Example directory first.
If you are setting
KeyboardAvoidingView class in storyboard assure module field is also
Please check official guide
github "APUtils/KeyboardAvoidingView" ~> 5.0
Then add both
ViewState frameworks to your project. Remove
APExtensionsViewState dependency if you previously had it.
KeyboardAvoidingView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KeyboardAvoidingView", '~> 5.0'
KeyboardAvoidingView class to any view in storyboard (usually it's base container) that you want to adjust it's bottom constraint or frame height to avoid keyboard, assure module field is also
It's also possible to create it from code:
let keyboardAvoidingView = KeyboardAvoidingView(frame: containerView.bounds) keyboardAvoidingView.translatesAutoresizingMaskIntoConstraints = true keyboardAvoidingView.autoresizingMask = [.flexibleWidth, .flexibleHeight] containerView.addSubview(keyboardAvoidingView)
In most cases it should be only one
KeyboardAvoidingView for screen. Be sure to not create nested
See example project for more details.
Usage together with IQKeyboardManager
KeyboardAvoidingView more likely will conflict with
IQKeyboardManager so you have to disable
IQKeyboardManager on the screen you are using
KeyboardAvoidingView. Please reffer to the
IQKeyboardManager documentation. More likely it'll look something like this:
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.
Anton Plebanovich, [email protected]
KeyboardAvoidingView is available under the MIT license. See the LICENSE file for more info.