Latest 1.0.2
License MIT
Platforms ios 9.0
Frameworks UIKit

Simple iOS Keyboard frame tracker for custom interactive Keyboard dismissal



  • [x] Very simple and easy to use API
  • [x] Provides both delegates and closure callbacks
  • [x] Can be used with any type of input views (UITextField, UITextView)
  • [x] Allows for interactive Keyboard dismissal in a UITabBarController with inputAccessoryView


To run the example project, clone the repo, and run the .xcworkspace.


AMKeyboardFrameTracker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'AMKeyboardFrameTracker'


  • Requires iOS 9.0+


let height = 60 // this should be your input view height
let keyboardFrameTrackerView = AMKeyboardFrameTrackerView.init(height: height)
inputTextView.inputAccessoryView = keyboardFrameTrackerView


if your inputView height changes dynamically depending on the content inside it, then you will need keep the inputAccessoryView height in sync with your inputView height, to do that you need to override the viewDidLayoutSubviews in your ViewController and use the code below

override func viewDidLayoutSubviews() {

or you can use layout constraints

var keyboardFrameTrackerViewHeightConstraint: NSLayoutConstraint!
override func viewDidLoad() {
    self.keyboardFrameTrackerView.delegate = self
    self.inputTextView.inputAccessoryView = self.keyboardFrameTrackerView
    self.keyboardFrameTrackerView.translatesAutoresizingMaskIntoConstraints = false
    self.keyboardFrameTrackerViewHeightConstraint = self.keyboardFrameTrackerView.heightAnchor.constraint(equalTo: self.inputTextView.heightAnchor, multiplier: 0)
    self.keyboardFrameTrackerViewHeightConstraint.isActive = true

then you you can update the constant in viewDidLayoutSubviews

override func viewDidLayoutSubviews() {
     self.keyboardFrameTrackerViewHeightConstraint.constant = self.inputTextView.frame.height

Closure Callbacks

keyboardFrameTrackerView.onKeyboardFrameDidChange = { [weak self] frame in
    guard let self = self else {return}
    print("Keyboard frame: ", frame)

Delegate Callbacks

keyboardFrameTrackerView.delegate = self
extension ExampleViewController: AMKeyboardFrameTrackerDelegate {
    func keyboardFrameDidChange(with frame: CGRect) {
        print("Keyboard frame: ", frame)

UITabBarController Support

First you need to add your inputView to you ViewController view as a normal subview and then set all your constraints and layout, you will need to have a bottomConstraints from your inputView to ViewController view and use the code below

extension ExampleViewController: AMKeyboardFrameTrackerDelegate {
    func keyboardFrameDidChange(with frame: CGRect) {
        let tabBarHeight = self.tabBarController?.tabBar.frame.height ?? 0.0
        let bottomSapcing = self.view.frame.height - frame.origin.y - tabBarHeight - self.keyboardFrameTrackerView.frame.height

        self.inputViewBottomConstraint.constant = bottomSapcing > 0 ? bottomSapcing : 0




AMKeyboardFrameTracker is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "AMKeyboardFrameTracker",
    "version": "1.0.2",
    "summary": "Simple iOS Keyboard frame tracker for custom interactive Keyboard dismissal",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "iAmrMohamed": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.2"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "swift_version": "5.0",
    "source_files": "AMKeyboardFrameTracker/Classes/**/*",
    "frameworks": "UIKit"

Pin It on Pinterest

Share This