Skip to content

Repository files navigation

KeyboardObserver

Provides a reactive way to observe the changes of the keyboard's frame using Swift Combine.

demo

Requirements

  • iOS 13.0+
  • Swift 5.10

Get Started

  1. Attach your view's anchor to the keyboardAreaLayoutGuide of your view.
chatBarView.bottomAnchor.constraint(equalTo: view.keyboardAreaLayoutGuide.topAnchor)
  1. You can also observe the change of the keyboard
view.keyboardObserver.keyboardHeightChange
.sink{ change inprint(change)}
  1. You can invalidate the observer at any time.
overridefunc viewWillAppear(_ animated:Bool){
super.viewWillAppear(animated)
view.keyboardObserver.validate()}overridefunc viewWillDisappear(_ animated:Bool){
super.viewWillDisappear(animated)
view.keyboardObserver.invalidate()}

Installation

Add the below line to your Package.swift file as a dependency:

.package(url:"https://github.com/DouKing/KeyboardObserver.git",.upToNextMajor(from:"1.0"))

Normally you'll want to depend on the KeyboardObserver target:

.product(name:"KeyboardObserver",package:"KeyboardObserver")

License

KeyboardObserver is under MIT license.

About

Provides a reactive way to observe the changes of keyboard using Swift Combine

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages