Swiftpack.co - APUtils/KeyboardAvoidingView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by APUtils.
APUtils/KeyboardAvoidingView 5.2.0
Simple solution for keyboard avoiding. View that manages it's bottom constraint constant or frame height to avoid keyboard
⭐️ 17
🕓 2 weeks ago
iOS
.package(url: "https://github.com/APUtils/KeyboardAvoidingView.git", from: "5.2.0")

KeyboardAvoidingView

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.

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.2

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.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: "https://github.com/APUtils/KeyboardAvoidingView.git", .upToNextMajor(from: "5.2.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, anton.plebanovich@gmail.com

License

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

GitHub

link
Stars: 17
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics