Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Typist
- protocol KeyboardAware {
- var keyboard: Typist { get }
- var contentInset: UIEdgeInsets { get }
- var scrollIndicatorInsets: UIEdgeInsets { get }
- }
- extension KeyboardAware where Self: UIScrollView {
- func observeKeyboard() {
- keyboard.on(event: .willShow) { options in
- self.contentInset.bottom = options.startFrame.height
- self.scrollIndicatorInsets = self.contentInset
- }.on(event: .willHide) { options in
- UIView.animate(withDuration: options.animationDuration) {
- self.contentInset.bottom = 0
- self.scrollIndicatorInsets = self.contentInset
- }
- }.start()
- }
- }
- class ScrollView: UIScrollView, KeyboardAware {
- let keyboard = Typist.shared
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement