GithubHelp home page GithubHelp logo

jqhee / gesturepassword Goto Github PK

View Code? Open in Web Editor NEW

This project forked from huangboju/gesturepassword

0.0 2.0 0.0 1.97 MB

GesturePassword 是一个Swift的手势密码库

License: MIT License

Swift 99.28% Objective-C 0.06% Ruby 0.66%

gesturepassword's Introduction

GesturePassword 是一个Swift的手势密码库

  • 采用底层CALayer实现
  • 业务逻辑和UI分离,可以高度定制
  • 支持中英文
  • 采用UserDefaults和Keychain两套密码缓存机制

Cocoapods

pod 'GesturePassword'

1.设置密码

Alt text

2.验证密码

Alt text

3.修改密码

Alt text

Usage

  1. 将Lock.swift文件拖入你的工程
  2. 使用二次封装的AppLock类自己调用设置密码修改密码验证密码
let AppLock = Lock.shared

class Lock {

    static let shared = Lock()

    private init() {
        // 在这里自定义你的UI
        LockCenter.passwordKeySuffix = "user1"

//        LockCenter.usingKeychain = true
//        LockCenter.lineWidth = 2
//        LockCenter.lineWarnColor = .blue
    }

    func set(controller: UIViewController) {
        if hasPassword {
            print("密码已设置")
            print("🍀🍀🍀 \(password) 🍀🍀🍀")
        } else {
            showSetPattern(in: controller).successHandle = {
                LockCenter.set($0)
            }
        }
    }

    func verify(controller: UIViewController) {
        guard hasPassword else {
            print("❌❌❌ 还没有设置密码 ❌❌❌")
            return
        }

        print("密码已设置")
        print("🍀🍀🍀 \(password) 🍀🍀🍀")
        showVerifyPattern(in: controller).successHandle {
            $0.dismiss()
        }.overTimesHandle {
            LockCenter.removePassword()
            $0.dismiss()
            assertionFailure("你必须做错误超限后的处理")
        }.forgetHandle {
            $0.dismiss()
            assertionFailure("忘记密码,请做相应处理")
        }
    }

    func modify(controller: UIViewController) {
        guard hasPassword else {
            print("❌❌❌ 还没有设置密码 ❌❌❌")
            return
        }

        print("密码已设置")
        print("🍀🍀🍀 \(password) 🍀🍀🍀")
        showModifyPattern(in: controller).forgetHandle { _ in

            }.overTimesHandle { _ in

            }.resetSuccessHandle {
                print("🍀🍀🍀 \($0) 🍀🍀🍀")
        }
    }

    var hasPassword: Bool {
        // 这里密码后缀可以自己传值,默认为上面设置的passwordKeySuffix
        return LockCenter.hasPassword()
    }

    var password: String {
        return LockCenter.password() ?? ""
    }

    func removePassword() {
        // 这里密码后缀可以自己传值,默认为上面设置的passwordKeySuffix
        LockCenter.removePassword()
    }
}

版本记录

gesturepassword's People

Contributors

huangboju avatar

Watchers

James Cloos avatar JQ.MrHuang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.