Awesome
IQKeyboardNotification
Lightweight library to observe keyboard events with ease.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Installation
IQKeyboardNotification is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'IQKeyboardNotification'
Usage
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")
}
}
Author
Iftekhar Qurashi hack.iftekhar@gmail.com
Flow
License
IQKeyboardNotification is available under the MIT license. See the LICENSE file for more info.