Skip to content

carabina/PrettyKeyboardHelper

 
 

Repository files navigation

PrettyKeyboardHelper

Twitter: @nab0y4enko Cocoapod [License] (https://github.com/nab0y4enko/PrettyKeyboardHelper/blob/master/LICENSE)

A safe helper for keyboard notifications written in Swift.

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
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)
    }
}

Or easiest way

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

Requirements

  • iOS 9.0 or higher
  • Xcode 8.0 (swift 3.0) or higher

License

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

About

A safe helper for keyboard notifications written in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 83.4%
  • Ruby 10.0%
  • Objective-C 6.6%