{"id":21374061,"url":"https://github.com/chongzone/KeenCodeUnit","last_synced_at":"2025-07-13T08:32:19.997Z","repository":{"id":56917851,"uuid":"414550420","full_name":"chongzone/KeenCodeUnit","owner":"chongzone","description":"自定义的验证码、支付密码文本框，支持明文、密文输入等，支持内容的验证错误处理","archived":false,"fork":false,"pushed_at":"2021-10-27T14:19:19.000Z","size":3144,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-12T12:04:29.217Z","etag":null,"topics":["codeunit","ios","ios-swift","objective-c","password","swift","verifycode","xcode"],"latest_commit_sha":null,"homepage":"https://github.com/chongzone/KeenCodeUnit","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/chongzone.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":"2021-10-07T10:09:00.000Z","updated_at":"2024-10-14T05:28:09.000Z","dependencies_parsed_at":"2022-08-21T04:50:51.211Z","dependency_job_id":null,"html_url":"https://github.com/chongzone/KeenCodeUnit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chongzone%2FKeenCodeUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chongzone%2FKeenCodeUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chongzone%2FKeenCodeUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chongzone%2FKeenCodeUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chongzone","download_url":"https://codeload.github.com/chongzone/KeenCodeUnit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225868612,"owners_count":17537085,"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":["codeunit","ios","ios-swift","objective-c","password","swift","verifycode","xcode"],"created_at":"2024-11-22T08:29:40.168Z","updated_at":"2024-11-22T08:30:10.186Z","avatar_url":"https://github.com/chongzone.png","language":"Swift","readme":"![KeenCodeUnit](https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCodeUnitLogo.png)\n\n![CI Status](https://img.shields.io/travis/chongzone/KeenCodeUnit.svg?style=flat)\n![](https://img.shields.io/badge/swift-5.0%2B-orange.svg?style=flat)\n![](https://img.shields.io/badge/pod-v1.0.3-brightgreen.svg?style=flat)\n![](https://img.shields.io/badge/platform-iOS9.0%2B-orange.svg?style=flat)\n![](https://img.shields.io/badge/license-MIT-blue.svg)\n\n## 效果样式 \n\n样式说明 | Gif 图 |\n----|------|\n下划线 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_01.gif\" width=\"330\" height=\"95\"\u003e |\n下划线2 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_02.gif\" width=\"318\" height=\"97\"\u003e |\n下划线密文 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_03.gif\" width=\"318\" height=\"97\"\u003e |\n边框 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_04.gif\" width=\"318\" height=\"97\"\u003e |\n边框2 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_05.gif\" width=\"318\" height=\"97\"\u003e |\n边框3 |  \u003cimg src=\"https://raw.githubusercontent.com/chongzone/KeenCodeUnit/master/Resources/KeenCode_06.gif\" width=\"318\" height=\"97\"\u003e |\n\n## API 说明\n\n- [x] 自定义的验证码、支付密码输入文本框，支持明文、密文输入等 \n- [x] 支持内容的验证错误处理\n\n支持的布局样式\n```ruby\nenum Style {\n    /// 分割下划线\n    case splitline\n    /// 分割边框\n    case splitborder\n    /// 连续边框\n    case followborder\n}\n```\n\n在属性参数对象 `KeenCodeUnitAttributes` 中可查看支持定制的参数属性\n```ruby\n/// 视图背景色 默认 white\npublic var viewBackColor: UIColor = UIColor.white\n\n/// 样式 默认 splitline\npublic var style: KeenCodeUnitAttributes.Style = .splitline\n\n/// 位数 默认 6 位\npublic var count: Int = 6\n/// 控件间隔 默认 12 pt  style 为 followborder 失效\npublic var itemSpacing: CGFloat = 12\n/// 控件左右边距 默认 15 pt\npublic var itemPadding: CGFloat = 15\n/// 默认情况下首个控件是否高亮显示 默认 true\npublic var isFirstAlive: Bool = true\n/// 是否单个高亮 即仅针对获取焦点的控件高亮 默认 false 其中 style 为 followborder 失效\npublic var isSingleAlive: Bool = false\n/// 内容是否自动填写 默认 true\npublic var isAutoFillin: Bool = true\n/// 文本是否加密 默认 false\npublic var isSecureTextEntry: Bool = false\n\n/// 文本颜色 默认 black\npublic var textColor: UIColor = .black\n/// 文本字体 默认常规 15pt\npublic var textFont: UIFont = UIFont.systemFont(ofSize: 15, weight: .regular)\n\n/// 光标颜色 默认 blue\npublic var cursorColor: UIColor = .blue\n/// 光标宽度 默认 1.6pt\npublic var cursorWidth: CGFloat = 1.6\n/// 光标高度百分比 即占视图高度的百分比 默认 0.5\npublic var cursorHeightPercent: CGFloat = 0.5\n\n/// 下划线高度 默认 1pt\npublic var lineHeight: CGFloat = 1\n/// 下划线圆角 默认 高度 * 0.5\npublic var lineRadius: CGFloat = 0.5\n/// 下划线颜色 默认 lightGray\npublic var lineColor: UIColor = .lightGray\n/// 下划线高亮颜色 默认 black\npublic var lineHighlightedColor: UIColor = .black\n/// 下划线错误颜色 默认 red\npublic var lineErrorColor: UIColor = .red\n\n/// 边框高亮时是否视图呈现出覆盖完全 默认 true 仅针对 '连续边框' 样式有效\npublic var isSingleCoverAll: Bool = true\n/// 边框宽度 默认 1pt\npublic var borderWidth: CGFloat = 1\n/// 边框圆角 默认 4pt\npublic var borderRadius: CGFloat = 4\n/// 边框颜色 默认 lightGray\npublic var borderColor: UIColor = .lightGray\n/// 边框高亮颜色 默认 black\npublic var borderHighlightedColor: UIColor = .black\n/// 边框错误颜色 默认 red\npublic var borderErrorColor: UIColor = .red\n```\n\n## 使用介绍\n\n### `KeenCodeUnit` 示例\n\n```ruby\n/// 方式 1 通过代理配置属性参数、输入回调等\nlet rect = CGRect(x: 30, y: 200, width: CGFloat.screenWidth - 60, height: 44)\ncodeUnit = KeenCodeUnit(\n    frame: rect,\n    delegate: self\n)\n    .addViewTo(view)\n\n/// 方式 2 通过闭包处理输入回调\nlet attr = KeenCodeUnitAttributes()\ncodeUnit = KeenCodeUnit(\n    frame: rect,\n    attributes: attr,\n    callback: { codeText, complete in\n        if complete {         \n            /// 验证输入的是否为指定内容, 不是的话给出错误处理\n            if codeText != \"202103\" {\n                self.codeUnit.verifyErrorAction()\n            }\n            print(codeText)\n        }\n    }\n)\n    .addViewTo(view)\n\n/// 方式 3 通过闭包处理输入回调\nvar attr = KeenCodeUnitAttributes()\nattr.style = .followborder\ncodeUnit = KeenCodeUnit(\n    frame: rect,\n    attributes: attr\n)\n    .addViewTo(view)\ncodeUnit.callback = { (codeText, complete) in\n    if complete {\n        /// 验证输入的是否为指定内容, 不是的话给出错误处理\n        if codeText != \"202103\" {\n            self.codeUnit.verifyErrorAction()\n        }\n        print(codeText)\n    }\n}\n```\n\n### `KeenCodeUnitDelegate` 代理\n\n```ruby\n/// 属性参数 可选 不设置取默认值\n/// - Returns: 属性对象\nfunc attributesOfCodeUnit(for codeUnit: KeenCodeUnit) -\u003e KeenCodeUnitAttributes\n\n/// 输入回调事件 优先级高\nfunc codeUnit(_ codeUnit: KeenCodeUnit, codeText: String, complete: Bool)\n```\n\u003e 具体可下载查看源码实现 \n\n## 安装方式 \n\n### CocoaPods\n\n```ruby\nplatform :ios, '9.0'\nuse_frameworks!\n\ntarget 'TargetName' do\n\npod 'KeenCodeUnit'\n\nend\n```\n\u003e `iOS` 版本要求 `9.0+`\n\u003e `Swift` 版本要求 `5.0+`\n\n## Contact Me\n\nQQ: 2209868966\n邮箱: chongzone@163.com\n\n## License\n\nKeenCodeUnit is available under the MIT license. [See the LICENSE](https://github.com/chongzone/KeenCodeUnit/blob/main/LICENSE) file for more info.\n","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["CodeUnit-AuthenticationCode"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchongzone%2FKeenCodeUnit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchongzone%2FKeenCodeUnit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchongzone%2FKeenCodeUnit/lists"}