{"id":18974665,"url":"https://github.com/pujiaxin33/jxpatternlock","last_synced_at":"2025-11-10T12:04:50.327Z","repository":{"id":56916757,"uuid":"193689081","full_name":"pujiaxin33/JXPatternLock","owner":"pujiaxin33","description":"An easy-to-use, powerful, customizable pattern lock view in swift. 图形解锁／手势解锁 / 手势密码 / 图案密码 / 九宫格密码","archived":false,"fork":false,"pushed_at":"2020-06-23T08:13:05.000Z","size":115,"stargazers_count":236,"open_issues_count":0,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T12:39:04.217Z","etag":null,"topics":["gesture","gesturepassword","lock","password","pattern","patternlock","patternlockview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pujiaxin33.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-25T10:46:36.000Z","updated_at":"2025-03-22T20:50:38.000Z","dependencies_parsed_at":"2022-08-21T03:50:51.072Z","dependency_job_id":null,"html_url":"https://github.com/pujiaxin33/JXPatternLock","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pujiaxin33%2FJXPatternLock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pujiaxin33%2FJXPatternLock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pujiaxin33%2FJXPatternLock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pujiaxin33%2FJXPatternLock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pujiaxin33","download_url":"https://codeload.github.com/pujiaxin33/JXPatternLock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931391,"owners_count":21827104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gesture","gesturepassword","lock","password","pattern","patternlock","patternlockview"],"created_at":"2024-11-08T15:15:44.007Z","updated_at":"2025-11-10T12:04:50.280Z","avatar_url":"https://github.com/pujiaxin33.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=center\u003e\u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/JXPatternLock.png\" width=\"468\" height=\"90\" /\u003e\u003c/div\u003e\n\n[![platform](https://img.shields.io/badge/platform-iOS-blue.svg?style=plastic)](#)\n[![languages](https://img.shields.io/badge/language-swift-blue.svg)](#) \n[![cocoapods](https://img.shields.io/badge/cocoapods-supported-4BC51D.svg?style=plastic)](https://cocoapods.org/pods/JXPatternLock)\n[![carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage/)\n[![support](https://img.shields.io/badge/support--ios-iOS9%2B-orange.svg)](#) \n\nAn easy-to-use, powerful, customizable pattern lock view in swift. 图形解锁／手势解锁 / 手势密码 / 图案密码 / 九宫格密码\n\n相比于其他同类三方库有哪些优势：\n- 完全面对协议编程，支持高度自定义**网格视图**和**连接线视图**，轻松实现各类不同需求；\n- 默认支持多种配置效果，支持大部分主流效果，引入就可以搞定需求；\n- 源码采用**Swift5**编写，通过泛型、枚举、函数式编程优化代码，具有更高的学习价值；\n- 后期会持续迭代，不断添加主流效果；\n\n## 效果预览\n\n\n说明 | Gif |\n----|------|\n箭头  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/arrow.gif\" width=\"336\" height=\"330\"\u003e |\n中间点自动连接 |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/autoConnect.gif\" width=\"336\" height=\"330\"\u003e |\n小灰点  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/grayRound.gif\" width=\"336\" height=\"330\"\u003e |\n小白点  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/whiteRound.gif\" width=\"336\" height=\"330\"\u003e |\n荧光蓝  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/nightBlue.gif\" width=\"336\" height=\"330\"\u003e |\nfill白色  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/whiteFill.gif\" width=\"336\" height=\"330\"\u003e |\n阴影  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/shadow.gif\" width=\"336\" height=\"330\"\u003e |\n图片  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/image.gif\" width=\"336\" height=\"330\"\u003e |\n旋转(鸡你太美)  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/rotateImage.gif\" width=\"336\" height=\"330\"\u003e |\n破折线  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/dashLine.gif\" width=\"336\" height=\"330\"\u003e |\n图片连接线（箭头）  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/arrowLine.gif\" width=\"336\" height=\"330\"\u003e |\n图片连接线（小鱼儿）  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/fishLine.gif\" width=\"336\" height=\"330\"\u003e |\n设置密码  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/passwordSetup.gif\" width=\"336\" height=\"400\"\u003e |\n修改密码  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/passwordModify.gif\" width=\"336\" height=\"400\"\u003e |\n验证密码  |  \u003cimg src=\"https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/passwordVertify.gif\" width=\"336\" height=\"400\"\u003e |\n\n## 要求\n\n- iOS 9.0+\n- Xcode 10.2.1+\n- Swift 5.0\n\n## 安装\n\n### 手动\n\nClone代码，把Sources文件夹拖入项目，就可以使用了；\n\n### CocoaPods\n\n```ruby\ntarget '\u003cYour Target Name\u003e' do\n    pod 'JXPatternLock'\nend\n```\n先执行`pod repo update`，再执行`pod install`\n\n### Carthage\n在cartfile文件添加：\n```\ngithub \"pujiaxin33/JXPatternLock\"\n```\n然后执行`carthage update --platform iOS` 即可\n\n## 使用\n\n### 初始化`PatternLockViewConfig`\n\n#### 方式一：使用`LockConfig`\n`LockConfig`是默认提供的类，实现了`PatternLockViewConfig`协议。可以直接通过`LockConfig`的属性进行自定义。\n```Swift\nlet config = LockConfig()\nconfig.gridSize = CGSize(width: 70, height: 70)\nconfig.matrix = Matrix(row: 3, column: 3)\nconfig.errorDisplayDuration = 1\n```\n\n#### 方式二：新建实现`PatternLockViewConfig`协议的类\n该方式可以将所有配置细节聚集到自定义类的内部，外部只需要初始化自定义类即可。详情请参考demo里面的`ArrowConfig`类。这样有个好处就是，多个地方都需要用到同样配置的时候，只需要初始化相同的类，而不用像使用`LockConfig`那样，复制属性配置代码。\n```Swift\nstruct ArrowConfig: PatternLockViewConfig {\n    var matrix: Matrix = Matrix(row: 3, column: 3)\n    var gridSize: CGSize = CGSize(width: 70, height: 70)\n    var connectLine: ConnectLine?\n    var autoMediumGridsConnect: Bool = false\n    //其他属性配置！只是示例，就不显示所有配置项，影响文档长度\n}\n```\n\n### 配置`GridView`\n```Swift\nconfig.initGridClosure = {(matrix) -\u003e PatternLockGrid in\n    let gridView = GridView()\n    let outerStrokeLineWidthStatus = GridPropertyStatus\u003cCGFloat\u003e.init(normal: 1, connect: 2, error: 2)\n    let outerStrokeColorStatus = GridPropertyStatus\u003cUIColor\u003e(normal: tintColor, connect: tintColor, error: .red)\n    gridView.outerRoundConfig = RoundConfig(radius: 33, lineWidthStatus: outerStrokeLineWidthStatus, lineColorStatus: outerStrokeColorStatus, fillColorStatus: nil)\n    let innerFillColorStatus = GridPropertyStatus\u003cUIColor\u003e(normal: nil, connect: tintColor, error: .red)\n    gridView.innerRoundConfig = RoundConfig(radius: 10, lineWidthStatus: nil, lineColorStatus: nil, fillColorStatus: innerFillColorStatus)\n    return gridView\n}\n```\n\n### 配置`ConnectLine`\n```Swift\nlet lineView = ConnectLineView()\nlineView.lineColorStatus = .init(normal: tintColor, error: .red)\nlineView.triangleColorStatus = .init(normal: tintColor, error: .red)\nlineView.isTriangleHidden = false\nlineView.lineWidth = 3\nconfig.connectLine = lineView\n```\n\n### 初始化`PatternLockView`\n```Swift\nlockView = PatternLockView(config: config)\nlockView.delegate = self\nview.addSubview(lockView)\n```\n\n## 结构\n\n![structure](https://github.com/pujiaxin33/JXExampleImages/blob/master/PatternLock/JXPatternLockStructure.png)\n\n完全遵从面对协议开发。\n`PatternLockView`依赖于配置协议`PatternLockViewConfig`。\n`PatternLockViewConfig`依赖配置网格协议`PatternLockGrid`和连接线协议`ConnectLine`。\n\n## 补充\n\n如果刚开始使用`JXPatternLock`，当开发过程中需要支持某种特性时，请务必先搜索使用文档或者源代码。确认是否已经实现支持了想要的特性。请别不要文档和源代码都没有看，就直接提问，这对于大家都是一种时间浪费。如果没有支持想要的特性，欢迎提Issue讨论，或者自己实现提一个PullRequest。\n\n使用过程中，有任何建议或问题，可以通过以下方式联系我：\u003c/br\u003e\n邮箱：317437084@qq.com \u003c/br\u003e\n\n喜欢就star❤️一下吧\n\n## License\n\nJXPatternLock is released under the MIT license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpujiaxin33%2Fjxpatternlock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpujiaxin33%2Fjxpatternlock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpujiaxin33%2Fjxpatternlock/lists"}