IQKeyboardCore

CI Status Version License Platform

示例

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

要求

安装

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

pod 'IQKeyboardCore'

用法

IQKeyboardCore 不应独立使用。 它只是大多数与 IQKeyboard 相关的库的助手和扩展

这包含了 IQTextInputView 协议

@objc public protocol IQTextInputView where Self: UIView, Self: UITextInputTraits {
}

UITextField、UITextView 和 UISearchBar 是库中已知采用此协议的类

@objc extension UITextField: IQTextInputView {...}

@objc extension UITextView: IQTextInputView {...}

@objc extension UISearchBar: IQTextInputView {...}

此库还包含 IQEnableMode,供其他库使用

@objc public enum IQEnableMode: Int {
    case `default`
    case enabled
    case disabled
}

UIView 上还有其他扩展函数可用

public extension IQKeyboardExtension where Base: UIView {
    func viewContainingController() -> UIViewController?
    func superviewOf<T: UIView>(type classType: T.Type, belowView: UIView? = nil) -> T?
    func textFieldSearchBar() -> UISearchBar?
    func isAlertViewTextField() -> Bool
}

上面的扩展函数可以像下面这样使用

  view.iq.viewContainingController()
  view.iq.superviewOf(type: UIScrollView.self)
  view.iq.textFieldSearchBar()
  view.iq.isAlertViewTextField()

作者

hackiftekhar, ideviftekhar@gmail.com

许可证

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