|
1 |
| -RxKeyboard |
2 |
| -========== |
| 1 | +# RxKeyboard |
3 | 2 |
|
4 |
| -Reactive keyboard in iOS |
| 3 | + |
| 4 | +[](https://cocoapods.org/pods/RxKeyboard) |
| 5 | +[](https://github.com/Carthage/Carthage) |
| 6 | + |
| 7 | +RxKeyboard provides a reactive way of keyboard handling. Forget about `UIKeyboardWillShow` and `UIKeyboardWillHide`. It also perfectly works with `UIScrollViewKeyboardDismissMode.interactive`. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## At a Glance |
| 12 | + |
| 13 | +Observing keyboard frame: |
| 14 | + |
| 15 | +```swift |
| 16 | +RxKeyboard.instance.frame |
| 17 | + .drive(onNext: { frame in |
| 18 | + print(frame) |
| 19 | + }) |
| 20 | + .addDisposableTo(disposeBag) |
| 21 | +``` |
| 22 | + |
| 23 | +Observing keyboard visible height: |
| 24 | + |
| 25 | +```swift |
| 26 | +RxKeyboard.instance.visibleHeight |
| 27 | + .drive(onNext: { keyboardVisibleHeight in |
| 28 | + toolbarBottomConstraint.constant = -1 * keyboardVisibleHeight |
| 29 | + }) |
| 30 | + .addDisposableTo(disposeBag) |
| 31 | +``` |
| 32 | + |
| 33 | +> **Note**: In real world, you should use `setNeedsLayout` and `layoutIfNeeded`. See the [demo project](https://github.com/devxoul/RxKeyboard/blob/master/Demo/Sources/ViewControllers/ViewController.swift#L62-L70) for example. |
| 34 | + |
| 35 | +## Dependencies |
| 36 | + |
| 37 | +- [RxSwift](https://github.com/ReactiveX/RxSwift) (= 3.0.0-beta.2) |
| 38 | +- [RxCocoa](https://github.com/ReactiveX/RxSwift) (= 3.0.0-beta.2) |
| 39 | + |
| 40 | +## Requirements |
| 41 | + |
| 42 | +- Swift 3 |
| 43 | +- iOS 8+ |
| 44 | + |
| 45 | +## Installation |
| 46 | + |
| 47 | +- **Using [CocoaPods](https://cocoapods.org)**: |
| 48 | + |
| 49 | + ```ruby |
| 50 | + pod 'RxKeyboard', '~> 0.1' |
| 51 | + ``` |
| 52 | + |
| 53 | +- **Using [Carthage](https://github.com/Carthage/Carthage)**: |
| 54 | + |
| 55 | + ``` |
| 56 | + github "devxoul/RxKeyboard" ~> 0.1 |
| 57 | + ``` |
| 58 | + |
| 59 | +## License |
| 60 | + |
| 61 | +RxKeyboard is under MIT license. |
0 commit comments