KeyboardAvoidingView 5.2.0

KeyboardAvoidingView 5.2.0

LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2021
SPMSupports SPM

Maintained by Anton Plebanovich.

  • By
  • Anton Plebanovich


Carthage compatible Swift Package Manager 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.


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

GIF animation



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

Please check official guide


github "APUtils/KeyboardAvoidingView" ~> 5.2

Then add both KeyboardAvoidingView and 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.2'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding KeyboardAvoidingView as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "", .upToNextMajor(from: "5.2.0"))


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]


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])


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.