Latest 0.4.0
Homepage https://github.com/nab0y4enko/PrettyKeyboardHelper
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation, UIKit
Authors

Platform iOS
Swift 4.2 compatible
Cocoapod
Build Status
License
Twitter: @nab0y4enko

A safe helper for keyboard notifications written in Swift.

Demo
Demo

Installation

CocoaPods

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

pod 'PrettyKeyboardHelper'

Usage

  • Import module

    import PrettyKeyboardHelper
  • Create PrettyKeyboardHelper instance
    
    private var prettyKeyboardHelper: PrettyKeyboardHelper?

override func viewDidLoad() {
super.viewDidLoad()

prettyKeyboardHelper = PrettyKeyboardHelper(delegate: self)

}


- Implement `PrettyKeyboardHelperDelegate`

> Simple example

```Swift
extension ViewController: PrettyKeyboardHelperDelegate {

    func keyboardWillChange(_ keyboardInfo: PrettyKeyboardInfo) {
        bottomLayoutConstraint?.constant = keyboardInfo.estimatedKeyboardHeight

        //animating
        UIView.animate(withDuration: keyboardInfo.duration, delay: 0, options: keyboardInfo.animationOptions, animations: {
            self.view.layoutIfNeeded()
        }, completion: nil)
    }
}

Resize bottom constraint

extension ViewController: PrettyKeyboardHelperDelegate {

    func keyboardWillChange(_ keyboardInfo: PrettyKeyboardInfo) {
        bottomLayoutConstraint?.updateConstant(keyboardInfo: keyboardInfo)
    }
}

Resize bottom constraint with UITabBar

extension ViewController: PrettyKeyboardHelperDelegate {

    func keyboardWillChange(_ keyboardInfo: PrettyKeyboardInfo) {
        bottomLayoutConstraint?.updateConstant(with: keyboardInfo, bottomLayoutGuide: bottomLayoutGuide)
    }
}

Change insets for UIScrollView

extension ViewController: PrettyKeyboardHelperDelegate {

    func keyboardWillChange(_ keyboardInfo: PrettyKeyboardInfo) {
        tableView?.updateBottomInset(with: keyboardInfo)
    }
}

Change insets for UIScrollView with UITabBar


extension ViewController: PrettyKeyboardHelperDelegate {

    func keyboardWillChange(_ keyboardInfo: PrettyKeyboardInfo) {
        tableView?.updateBottomInset(with: keyboardInfo, bottomLayoutGuide: bottomLayoutGuide)
    }
}

Requirements

  • iOS 8.0 or higher
  • Xcode 10.0 (swift 4.2) or higher

License

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

Latest podspec

{
    "name": "PrettyKeyboardHelper",
    "version": "0.4.0",
    "summary": "A helper for keyboard notifications.",
    "description": "A safe helper for keyboard notifications written in Swift.",
    "homepage": "https://github.com/nab0y4enko/PrettyKeyboardHelper",
    "screenshots": [
        "https://raw.githubusercontent.com/nab0y4enko/PrettyKeyboardHelper/master/demo%201.gif",
        "https://raw.githubusercontent.com/nab0y4enko/PrettyKeyboardHelper/master/demo%202.gif"
    ],
    "license": "MIT",
    "authors": {
        "Oleksii Naboichenko": "[email protected]"
    },
    "social_media_url": "https://twitter.com/nab0y4enko",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/nab0y4enko/PrettyKeyboardHelper.git",
        "tag": "0.4.0"
    },
    "source_files": "PrettyKeyboardHelper/*.swift",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This