RxKeyboard是一个韩国人开发的响应式的iOS键盘组件,效果如下图所示:
示例代码:
RxKeyboard提供两种驱动方式:
///Anobservablekeyboardframe.letframe:Driver<CGRect>///Anobservablevisibleheightofkeyboard.Emitskeyboardheightifthekeyboardisvisible///or`0`ifthekeyboardisnotvisible.letvisibleHeight:Driver<CGFloat>///Samewith`visibleHeight`butonlyemitsvalueswhenkeyboardisabouttoshow.Thisis///usefulwhenadjustingscrollviewcontentoffset.letwillShowVisibleHeight:Driver<CGFloat>使用 RxKeyboard.instance 来获取单例实例
RxKeyboard.instance订阅 RxKeyboard.instance.frame 来侦听键盘帧的变化
RxKeyboard.instance.frame.drive(onNext:{frameinprint(frame)}).disposed(by:disposeBag)依赖RxSwift (>=4.4.0)RxCocoa (>=4.4.0)要求Swift4iOS8+
评论