Latest 1.2.0
Homepage https://github.com/menly/keyboarding-ios
License Apache License, Version 2.0
Platforms ios 11.0
Authors

Keyboarding


CI Status


Swift 4.2


Twitter

🤨 What is this?

A simple keyboard helper for handling the appearance of the iOS keyboard.

📝 Requirements

Name Minimum version
Swift 4.2
iOS 11.0

📲 Installation

Carthage

Add the following to your Cartfile:

github "menly/keyboarding-ios"

CocoaPods

Add the following to your podfile:

pod 'Keyboarding'

⌨️ Usage

Import the framework:

import Keyboarding

Create an instance of our keyboard helper in your controller:

private let keyboarding = Keyboarding()

Assign your controller to the delegate, and be able to respond to changes in the keyboard:

keyboarding.delegate = self

This will allow you to implement the 2 required functions that are called when the keyboard visability changes:

private func keyboardDidAppear(_ info: KeyboardInfo?, _ error: Error?) {
    if let error = error {
        /// Handle error.

    } else if let info = info {
        info.animateWithKeyboard({ [weak self] in
            self?.bottomAnchor?.constant = -info.endFrame.height
            self?.view.layoutIfNeeded()
        }, completion: nil)
    }
}

private func keyboardDidDisappear(_ info: KeyboardInfo?, _ error: Error?) {
    if let error = error {
        /// Handle error.

    } else if let info = info {
        info.animateWithKeyboard({ [weak self] in
            self?.bottomAnchor?.constant = 0
            self?.view.layoutIfNeeded()
        }, completion: nil)
    }
}

Make sure you add the delegate to the keyboard helper in the viewDidLoad or init method.
(just make sure it’s added before the keyboard notification fires):
This way it’s easy to handle the keyboard in your iOS app.

In the body of the functions above, you can do as you please with the KeyboardInfo struct.
In this example, I have used the helper method (animateWithKeyboard) on the class,
that allows you to use the same animations as the keyboard,
but you can also just access the properties of the KeyboardInfo struct and handle the animations yourself.

👋 Get in touch!

Keyboarding

Get in touch with us! Send us an email, say hi on twitter (@menlyhq) or check out our website.

📄 License

See the license file for more information.

The names and logos for Menly and their products are trademarks of Menly ApS.

Copyright (c) Menly ApS 2016-present.

Keyboarding

Latest podspec

{
    "name": "Keyboarding",
    "version": "1.2.0",
    "summary": "Keyboard helper for iOS",
    "homepage": "https://github.com/menly/keyboarding-ios",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Menly ApS": "[email protected]"
    },
    "source": {
        "git": "https://github.com/menly/keyboarding-ios.git",
        "tag": "1.2.0"
    },
    "source_files": "Sources/**/*.{h,m,swift}",
    "swift_version": "4.2",
    "platforms": {
        "ios": "11.0"
    }
}

Pin It on Pinterest

Share This