Lightweight library to observe keyboard events with ease.
To run the example project, clone the repo, and run pod install
from the Example directory first.
IQKeyboardNotification is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'IQKeyboardNotification'
To observe keyboard events, subscribe to the keyboard events:-
import IQKeyboardNotification
class ViewController: UIViewController {
private let keyboard: IQKeyboardNotification = .init()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Subscribe
keyboard.subscribe(identifier: "YOUR_UNIQUE_IDENTIFIER") { event, frame in
print(frame)
// Write your own logic here based on event and keyboard frame
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Unsubscribe
keyboard.unsubscribe(identifier: "YOUR_UNIQUE_IDENTIFIER")
}
}
Iftekhar Qurashi hack.iftekhar@gmail.com
IQKeyboardNotification is available under the MIT license. See the LICENSE file for more info.