Latest 1.2.3
Homepage https://github.com/nixzhu/KeyboardMan
License MIT
Platforms ios 8.0, requires ARC
Authors


We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistakes. Even more, we need to handle the bug of system fire keyboard notifications.

But KeyboardMan will make it simple & easy.

另有中文介绍

Requirements

Swift 4.2, iOS 8.0

(Swift 3, use version 1.1.0)

Example

import KeyboardMan

Do animation with keyboard appear/disappear:

let keyboardMan = KeyboardMan()

keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in

    print("appear (appearPostIndex), (keyboardHeight), (keyboardHeightIncrement)n")

    if let self = self {

        self.tableView.contentOffset.y += keyboardHeightIncrement
        self.tableView.contentInset.bottom = keyboardHeight + self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = keyboardHeight
        self.view.layoutIfNeeded()
    }
}

keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in

    print("disappear (keyboardHeight)n")

    if let self = self {

        self.tableView.contentOffset.y -= keyboardHeight
        self.tableView.contentInset.bottom = self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = 0
        self.view.layoutIfNeeded()
    }
}

For more specific information, you can use keyboardInfo that KeyboardMan post:

keyboardMan.postKeyboardInfo = { [weak self] keyboardMan, keyboardInfo in
    // TODO
}

Check the demo for more information.

Installation

Feel free to drag KeyboardMan.swift to your iOS Project. But it’s recommended to use Carthage (or CocoaPods).

Carthage

github "nixzhu/KeyboardMan"

CocoaPods

pod 'KeyboardMan'

Contact

NIX @nixzhu

License

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

Latest podspec

{
    "name": "KeyboardMan",
    "version": "1.2.3",
    "summary": "KeyboardMan helps you do keyboard animation.",
    "description": "We may need keyboard infomation from keyboard notification to do animation.nHowever, the approach is complicated and easy to make mistakes.nBut KeyboardMan will make it simple & easy.",
    "homepage": "https://github.com/nixzhu/KeyboardMan",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "nixzhu": "[email protected]"
    },
    "social_media_url": "https://twitter.com/nixzhu",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/nixzhu/KeyboardMan.git",
        "tag": "1.2.3"
    },
    "source_files": "KeyboardMan/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This