Skip to content

Tiny UIViewController category that provides handy way for keyboard handling logic.

License

Notifications You must be signed in to change notification settings

podkovyrin/UIViewController-KeyboardAdditions

Repository files navigation

UIViewController-KeyboardAdditions

Version License Platform

Swift Version

For Swift compatible version check out Keyboardy

Description

UIViewController+KeyboardAdditions category simplifies keyboard handling logic by extending UIViewController class with several simple methods. Supports both AutoLayout and frame-based animations.

UIViewController-KeyboardAdditions Demo GIF

Usage

  1. Import category #import <UIViewController-KeyboardAdditions/UIViewController+KeyboardAdditions.h>

  2. Register to keyboard notifications in -viewWillAppear::

[self ka_startObservingKeyboardNotifications];
  1. Unregister from notifications in -viewWillDisappear::
[self ka_stopObservingKeyboardNotifications];
  1. Perform any layout with same animation options as keybord:
- (void)ka_keyboardShowOrHideAnimationWithHeight:(CGFloat)height
                               animationDuration:(NSTimeInterval)animationDuration
                                  animationCurve:(UIViewAnimationCurve)animationCurve {

    self.containerViewBottomConstraint.constant = height;
    [self.view layoutIfNeeded];
}

Example

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

Installation

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

pod "UIViewController-KeyboardAdditions"

Author

Andrew Podkovyrin, podkovyrin@gmail.com

License

UIViewController-KeyboardAdditions is available under the MIT license. See the LICENSE file for more info.

About

Tiny UIViewController category that provides handy way for keyboard handling logic.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published