key

Keyboardy

UIViewController extension for convenient keyboard management.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

113

Maintenance

Last Commit

2yrs ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

Keyboardy

Version Carthage Compatible Accio supported License Platform

Description

Keyboardy extends UIViewController with few simple methods and provides delegate for handling keyboard appearance notifications.

  • Keyboardy is just wrapper on UIKeyboardWillShowNotification and UIKeyboardWillHideNotification notifications.
  • Supports both AutoLayout and frame-based animations.
  • Swift implementation.
  • Without any hacks like method swizzling and magic numbers (ex., curve << 16).
Keyboardy Demo GIF

Usage

  • Import Keyboardy module
import Keyboardy
  • Register for keyboard notifications
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    registerForKeyboardNotifications(self)
}
  • Unregister from keyboard notifications
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    unregisterFromKeyboardNotifications()
}
  • Implement KeyboardStateDelegate
extension ViewController: KeyboardStateDelegate {

    func keyboardWillTransition(_ state: KeyboardState) {
        // keyboard will show or hide
    }

    func keyboardTransitionAnimation(_ state: KeyboardState) {
        switch state {
        case .activeWithHeight(let height):
            textFieldContainerBottomConstraint.constant = height
        case .hidden:
            textFieldContainerBottomConstraint.constant = 0.0
        }

        view.layoutIfNeeded()
    }

    func keyboardDidTransition(_ state: KeyboardState) {
        // keyboard animation finished
    }
}

Example

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

Requirements

Swift 5, iOS 8

Installation via CocoaPods

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

pod "Keyboardy"

Installation via Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Keyboardy into your Xcode project using Carthage, specify it in your Cartfile:

github "podkovyrin/Keyboardy"

Installation via Accio

  1. Add the following to your Package.swift:

    .package(url: "https://github.com/podkovyrin/Keyboardy.git", .upToNextMajor(from: "0.2.7")),
    
  2. Next, add Keyboardy to your App targets dependencies like so:

    .target(name: "App", dependencies: ["Keyboardy"]),
    
  3. Then run accio update.

Author

Andrew Podkovyrin, podkovyrin@gmail.com

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100