Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import Typist
  2.  
  3. protocol KeyboardAware {
  4. var keyboard: Typist { get }
  5. var contentInset: UIEdgeInsets { get }
  6. var scrollIndicatorInsets: UIEdgeInsets { get }
  7. }
  8.  
  9. extension KeyboardAware where Self: UIScrollView {
  10. func observeKeyboard() {
  11. keyboard.on(event: .willShow) { options in
  12. self.contentInset.bottom = options.startFrame.height
  13. self.scrollIndicatorInsets = self.contentInset
  14. }.on(event: .willHide) { options in
  15. UIView.animate(withDuration: options.animationDuration) {
  16. self.contentInset.bottom = 0
  17. self.scrollIndicatorInsets = self.contentInset
  18. }
  19. }.start()
  20. }
  21. }
  22.  
  23. class ScrollView: UIScrollView, KeyboardAware {
  24. let keyboard = Typist.shared
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement