KeyboardNotification 2.0.1

KeyboardNotification 2.0.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2019年7月
SPM支持 SPM

KeyboardNotification 维护。



  • Swifty-iOS

KeyboardNotification

KeyboardNotification 协议有助于获取所有键盘事件,如 显示/隐藏/框架更改,以及键盘的 框架大小

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要在使用 CocoaPods 的 Xcode 项目中集成 KeyboardNotification,在您的 Podfile 中指定它

target '<Your Target Name>' do
    pod 'KeyboardNotification'
end

然后,运行以下命令

$ pod install

如何使用

使用起来非常简单,只需将 KeyboardNotification 协议应用于您的 Controller 类或任何类。为期望的 Notification.Keyboard 类型注册您的类。

class ViewController: UIViewController, KeyboardNotification {
	...
    override func viewDidLoad(_ animated: Bool) {
        super.viewDidLoad(animated)
        // Register Keboard notification with inline closure
         registerKeyboardNotification(.willShow) { note _ in 
         // Get notifcation when Keyboard will appears

         }

         // register Keyboard notification with inline function
         registerKeyboardNotification(.willHide, handler: willHideKeyboard)
    }
	
    func willHideKeyboard(_ note: Notification) {
        // Write your code while hiding keyboard
        ....
        // Access keyboard frame
        let frame = note.keyboardFrame

    }
}

更多详情请查阅示例项目。

许可协议

MIT