GPassword 1.0.9

GPassword 1.0.9

lijie维护。



GPassword 1.0.9

  • leoli

GPassword

GPassword

Swift 中的简单手势密码

中文版本参考这里

功能

  • 使用代理为手势视图传递密码
  • 使用 CAShapeLayer、UIBezierPath 绘制以获得良好的性能
  • 支持定义 3*34*4... 矩阵
  • 支持定义许多种普通和选中样式
  • 使用 Keychain 和 UserDefaults 保存信息

屏幕截图

要求

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0+

安装

CocoaPods

pod "GPassword"

或者您可以将源文件拖入您的项目中。

使用说明

首先自定义UI样式,你需要以下内容

GPassword.config { (options) in
    options.connectLineStart = .border
    options.normalstyle = .innerFill
    options.isDrawTriangle = true
    options.matrixNum = 3
}

然后你可以使用 Box.swift 或将其添加到 UIViewController 中

fileprivate lazy var passwordBox: Box = {
    let box = Box(frame: CGRect(x: 50, y: 200, width: GWidth - 2 * 50, height: 400))
    box.delegate = self
    return box
}()

然后你需要实现两个代理方法,你应在其中编写业务逻辑,sendTouchPoint 可以发送完整的密码,而 touchesEnded 可以根据类型(设置/验证/修改)处理业务逻辑

extension PasswordViewController: EventDelegate {
    func sendTouchPoint(with tag: String) {
        password += tag
        // get complete password
    }
    
    func touchesEnded() {
        // write business logics according to type
    }
}

更多详细信息可以参考示例项目中的 PasswordViewController.swift,我已提供一个示例。

许可证

GPassword 使用 MIT 许可证发布。有关详细信息,请参阅 LICENSE