IQKeyboardToolbar

CI Status Version License Platform

Screenshot1 Screenshot2 Screenshot3 Screenshot4

示例

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

要求

安装

IQKeyboardToolbar 可通过 CocoaPods 获取。要安装它,只需将以下行添加到你的 Podfile 中

pod 'IQKeyboardToolbar'

用法

这个库可以用来给键盘添加工具栏

上一个、下一个和完成按钮

        textField.iq.addPreviousNextDone(target: self,
                                         previousAction: #selector(textField1PreviousAction),
                                         nextAction: #selector(textField1NextAction),
                                         doneAction: #selector(doneAction), showPlaceholder: true)

带有自定义标题或图像的上一个、下一个和右侧按钮

        textField.iq.addPreviousNextRight(target: self,
                                          previousConfiguration: .init(title: "Prev", action: #selector(textView1PreviousAction)),
                                          nextConfiguration: .init(title: "Next", action: #selector(textView1NextAction)),
                                          rightConfiguration: .init(image: UIImage(systemName: "chevron.down")!, action: #selector(doneAction)),
                                          title: "Text View 1")

动作按钮

        textField.iq.addDone(target: self,
                             action: #selector(doneAction),
                             title: "Select Account")
        textField.iq.toolbar.titleBarButton.setTarget(self,
                                                      action: #selector(selectAccount))

额外的引导按钮和尾随按钮

        textField.iq.toolbar.additionalLeadingItems = [.init(barButtonSystemItem: .add, target: self, action: #selector(addAction))]
        textField.iq.toolbar.additionalTrailingItems = [.init(barButtonSystemItem: .camera, target: self, action: #selector(cameraAction))]
        textField.iq.addToolbar(target: self,
                                previousConfiguration: nil,
                                nextConfiguration: .init(title: "Next", action: #selector(doneAction)),
                                rightConfiguration: .init(title: "Finish", action: #selector(doneAction)),
                                title: "TextView 2")

隐藏占位符

        textField1.iq.hidePlaceholder = true

自定义占位符

        textField1.iq.placeholder = "My Own Placeholder"

作者

Iftekhar Qurashi hack.iftekhar@gmail.com

许可证

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