Skip to content

Commit 86e4a0b

Browse files
committed
Update README.md
1 parent 73ce1bf commit 86e4a0b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
RxKeyboard provides a reactive way of observing keyboard frame changes. Forget about keyboard notifications. It also perfectly works with `UIScrollViewKeyboardDismissMode.interactive`.
99

10-
![rxkeyboard](https://cloud.githubusercontent.com/assets/931655/19223656/14bd915c-8eb0-11e6-93ea-7618fc9c5d81.gif)
11-
12-
> ▲ Interactive keyboard dismissing in UITextView.
10+
![rxkeyboard-message](https://cloud.githubusercontent.com/assets/931655/22062707/625eea7a-ddbe-11e6-9984-529abae1bd1a.gif)
11+
![rxkeyboard-textview](https://cloud.githubusercontent.com/assets/931655/19223656/14bd915c-8eb0-11e6-93ea-7618fc9c5d81.gif)
1312

1413
## Getting Started
1514

@@ -22,6 +21,10 @@ let frame: Driver<CGRect>
2221
/// An observable visible height of keyboard. Emits keyboard height if the keyboard is visible
2322
/// or `0` if the keyboard is not visible.
2423
let visibleHeight: Driver<CGFloat>
24+
25+
/// Same with `visibleHeight` but only emits values when keyboard is about to show. This is
26+
/// useful when adjusting scroll view content offset.
27+
let willShowVisibleHeight: Driver<CGFloat>
2528
```
2629

2730
Use `RxKeyboard.instance` to get singleton instance.
@@ -52,6 +55,16 @@ RxKeyboard.instance.frame
5255
.addDisposableTo(disposeBag)
5356
```
5457

58+
- <a name="tip-content-inset" href="#tip-content-offset">🔗</a> **I want to adjust `UIScrollView`'s `contentOffset` to fit keyboard height.**
59+
60+
```swift
61+
RxKeyboard.instance.willShowVisibleHeight
62+
.drive(onNext: { keyboardVisibleHeight in
63+
scrollView.contentInset.offset.y += keyboardVisibleHeight
64+
})
65+
.addDisposableTo(disposeBag)
66+
```
67+
5568
- <a name="tip-toolbar" href="#tip-toolbar">🔗</a> **I want to make `UIToolbar` move along with the keyboard in an interactive dismiss mode. (Just like the wonderful GIF above!)**
5669

5770
If you're not using Auto Layout:
@@ -74,7 +87,7 @@ RxKeyboard.instance.frame
7487
.addDisposableTo(disposeBag)
7588
```
7689

77-
> **Note**: In real world, you should use `setNeedsLayout()` and `layoutIfNeeded()` with animation block. See the [demo project](https://github.com/devxoul/RxKeyboard/blob/master/Demo/Sources/ViewControllers/ViewController.swift#L62-L70) for example.
90+
> **Note**: In real world, you should use `setNeedsLayout()` and `layoutIfNeeded()` with animation block. See the [demo project](https://github.com/RxSwiftCommunity/RxKeyboard/blob/master/Demo/Sources/ViewControllers/MessageListViewController.swift#L92-L105) for example.
7891

7992
- Anything else? Please open an issue or make a Pull Request.
8093

0 commit comments

Comments
 (0)