使用Swift编写的iOS的AutoKeyboard
轻松实现自动键盘处理。这是完全自动化的键盘处理。就像在Android中一样,当键盘出现时无需调整视图大小。它更新与bottomLayoutGuide
或safeAreaLayoutGuide
相关的约束。就像bottomLayoutGuide
或safeAreaLayoutGuide
一样,随着键盘的移动而上移和下移。只需进行register
和unResgister
即可。
特性
- 添加了对safeAreaLayoutGuide的支持。
- 添加了对UITabBarController的支持。
- 添加了对UIViewController扩展的支持,无需扩展类。
- 支持设备旋转。
- 支持多个UIViewController。
- 集成极其简单。
- 随着键盘自动更改底部约束。
- 具有动画的调整大小。
- 无需编写额外代码。
- 只需在
viewDidLoad
中调用registerAutoKeyboard
即可。 - 支持键盘的willShow、didShow、willHide、didHide、willChangeFrame、didChangeFrame回调。
- 关于保持scrollView滚动位置的示例
- 可注册或禁用其他约束。
运行时要求
- iOS8.0或更高版本
- Xcode 8.0 - Swift 3.0或更高版本
使用说明
基本使用
- 向
bottomLayoutGuide
或safeAreaLayoutGuide
添加约束,当键盘出现时它们将更新。 - 只是注册您的特定UIViewController。
override func viewDidLoad() {
registerAutoKeyboard()
}
高级使用
registerAutoKeyboard(enable: [lblBottom], disable: [btnShowScrollBottom]) { (result) in
print("keyboard status \(result.status)")
switch result.status {
case .willShow:
// ...
case .didShow:
// ...
case .willHide:
// ...
case .didHide:
// ...
}
}
如果您有自定义标签栏,返回其高度
extension ViewController: AutoKeyboardOptions {
var customTabbarExtraHeight: CGFloat { 50 }
}
安装
CocoaPods
要使用CocoaPods将AutoKeyboard集成到Xcode项目中,请在您的Podfile
中指定它,并运行pod install
。
platform :ios, '8.0'
use_frameworks!
pod 'AutoKeyboard' // for swift 5.0
pod 'AutoKeyboard', '~> 1.4.3' // for swift 4.2
然后 导入AutoKeyboard
Carthage
即将推出
贡献
欢迎贡献!
许可证
本项目采用MIT许可证,详情请参阅LICENSE.md文件