SwiftMaterialKeyboard 0.1.11

SwiftMaterialKeyboard 0.1.11

Chinh Nguyen 维护。



 
依赖项
SnapKit~> 4.0
RxSwift~> 4.0
RxCocoa~> 4.0
Material~> 2.12
 

  • Chinh Nguyen

SwiftMaterialKeyboard

CI Status Version License Platform

说明

在某些应用程序中,Apple 提供的默认键盘根本不够用,我们需要更多控制键盘的位置和行为。例如,我们需要一个更小且始终可见的 Qwerty 键盘,可以折叠到屏幕角落,而不是占据屏幕的一半。

示例

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

需求

安装

SwiftMaterialKeyboard通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中。

pod 'SwiftMaterialKeyboard'

创建键盘

要创建自定义键盘,创建一个从MaterialKeyboard继承的新类,通过重写rowCountcolumnCount来定义所需的行数和列数。每个键会像HTML表格的单元格一样放置,具有row(行)、column(列)以及所需的rowSpancolumnSpan(跨行跨列)位置。

这是在Example项目中可以找到的PinPad

class PinPad: MaterialKeyboard {
    override var rowCount: Int { return 4 }
    override var columnCount: Int { return 4 }
    override func createButtons() -> [KeyboardButton] {
        let prev = KeyboardButton.create(for: FAKMaterialIcons.longArrowTabIcon(withSize: 24), row: 0, column: 3, action: .next)
        prev.transform = CGAffineTransform(rotationAngle: .pi)
        return [
            KeyboardButton.create(for: "1", row: 0, column: 0),
            KeyboardButton.create(for: "2", row: 0, column: 1),
            KeyboardButton.create(for: "3", row: 0, column: 2),
            KeyboardButton.create(for: "4", row: 1, column: 0),
            KeyboardButton.create(for: "5", row: 1, column: 1),
            KeyboardButton.create(for: "6", row: 1, column: 2),
            KeyboardButton.create(for: "7", row: 2, column: 0),
            KeyboardButton.create(for: "8", row: 2, column: 1),
            KeyboardButton.create(for: "9", row: 2, column: 2),
            KeyboardButton.create(for: "0", row: 3, column: 1),
            KeyboardButton.create(for: "CLR", row: 3, column: 0, action: .clear),
            KeyboardButton.create(for: FAKMaterialIcons.arrowLeftIcon(withSize: 24), row: 3, column: 2, action: .backspace),
            prev,
            KeyboardButton.create(for: FAKMaterialIcons.longArrowTabIcon(withSize: 24), row: 1, column: 3, action: .next),
            KeyboardButton.create(for: FAKMaterialIcons.longArrowReturnIcon(withSize: 24), row: 2, column: 3, rowSpan: 2)
        ]
    }
}

在真实应用中的样子如下所示。

作者

Chinh Nguyen,[email protected]

许可证

SwiftMaterialKeyboard在MIT许可下提供。有关更多信息,请参阅LICENSE文件。