IQKeyboardNotification

轻量级库,可轻松观察键盘事件。

CI Status Version License Platform

Screenshot

示例

要运行示例项目,请克隆存储库,然后首先从示例目录运行 pod install

要求

安装

IQKeyboardNotification 可通过 CocoaPods 获得。 要安装它,只需将以下行添加到您的 Podfile 中

pod 'IQKeyboardNotification'

用法

要观察键盘事件,请订阅键盘事件:-

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

流程

Screenshot

许可证

IQKeyboardNotification 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。