RxKeyboard - 响应式的 iOS 键盘组件


MIT
iOS
Swift

软件简介

RxKeyboard 是一个韩国人开发的响应式的 iOS 键盘组件,效果如下图所示:


示例代码:

RxKeyboard 提供两种驱动方式:

/// An observable keyboard frame.
let frame: Driver<CGRect>

/// An observable visible height of keyboard. Emits keyboard height if the keyboard is visible
/// or `0` if the keyboard is not visible.
let visibleHeight: Driver<CGFloat>

/// Same with `visibleHeight` but only emits values when keyboard is about to show. This is
/// useful when adjusting scroll view content offset.
let willShowVisibleHeight: Driver<CGFloat>

使用 RxKeyboard.instance 来获取单例实例

RxKeyboard.instance

订阅 RxKeyboard.instance.frame 来侦听键盘帧的变化

RxKeyboard.instance.frame
  .drive(onNext: { frame in
    print(frame)
  })
  .disposed(by: disposeBag)

依赖

要求

  • Swift 4
  • iOS 8+