KeyboardAvoidingView 5.0.1

KeyboardAvoidingView 5.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2020
SPMSupports SPM

Maintained by Anton Plebanovich.



  • By
  • Anton Plebanovich

KeyboardAvoidingView

Carthage compatible Version License Platform CI Status

Simple solution for keyboard avoiding. View that manages it's bottom constraint constant or frame height to avoid keyboard.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

GIF animation

Installation

Carthage

If you are setting KeyboardAvoidingView class in storyboard assure module field is also KeyboardAvoidingView

Please check official guide

Cartfile:

github "APUtils/KeyboardAvoidingView" ~> 5.0

Then add both KeyboardAvoidingView and ViewState frameworks to your project. Remove APExtensionsViewState dependency if you previously had it.

CocoaPods

KeyboardAvoidingView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "KeyboardAvoidingView", '~> 5.0'

Usage

Just set 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 KeyboardAvoidingView.

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 KeyboardAvoidingView's.

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:

IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(contentsOf: [MyViewController.self])

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

Anton Plebanovich, [email protected]

License

KeyboardAvoidingView is available under the MIT license. See the LICENSE file for more info.