UIViewController-KeyboardAdditions 1.2.2

UIViewController-KeyboardAdditions 1.2.2

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2020年10月

Andrew Podkovyrin 维护。



UIViewController-KeyboardAdditions

Version License Platform

Swift 版本

有关 Swift 兼容版本的详细信息,请参阅 Keyboardy

描述

UIViewController+KeyboardAdditions 类别通过向 UIViewController 类扩展多个简单方法,简化了键盘处理逻辑。支持 AutoLayout 和基于 frame 的动画。

UIViewController-KeyboardAdditions Demo GIF

用法

  1. 导入类别 #import <UIViewController-KeyboardAdditions/UIViewController+KeyboardAdditions.h>

  2. -viewWillAppear: 中注册键盘通知

[self ka_startObservingKeyboardNotifications];
  1. -viewWillDisappear: 中注销通知
[self ka_stopObservingKeyboardNotifications];
  1. 使用与键盘相同的动画选项进行布局
- (void)ka_keyboardShowOrHideAnimationWithHeight:(CGFloat)height
                               animationDuration:(NSTimeInterval)animationDuration
                                  animationCurve:(UIViewAnimationCurve)animationCurve {

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

示例

要运行示例项目,请克隆存储库,然后从Example目录运行pod install

安装

UIViewController-KeyboardAdditions可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中。

pod "UIViewController-KeyboardAdditions"

作者

Andrew Podkovyrin,[email protected]

许可

UIViewController-KeyboardAdditions按照MIT许可提供。有关更多信息,请参阅LICENSE文件。