{"id":13696368,"url":"https://github.com/CRAnimation/CRBoxInputView","last_synced_at":"2025-05-03T17:31:01.191Z","repository":{"id":45588441,"uuid":"163955606","full_name":"CRAnimation/CRBoxInputView","owner":"CRAnimation","description":"Verify code input view. Support security type for password.短信验证码输入框，支持密文模式","archived":false,"fork":false,"pushed_at":"2023-03-13T09:06:00.000Z","size":3893,"stargazers_count":984,"open_issues_count":19,"forks_count":130,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-05T05:49:34.209Z","etag":null,"topics":["mobile","password","phone","phone-number","placeholder","uitextfield","uitextview","verifycode","verifycodeview"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/CRAnimation.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,"governance":null}},"created_at":"2019-01-03T10:03:04.000Z","updated_at":"2024-11-01T11:09:39.000Z","dependencies_parsed_at":"2022-08-28T05:00:48.362Z","dependency_job_id":"893dc44d-3462-49b8-87ad-cebda1ec645e","html_url":"https://github.com/CRAnimation/CRBoxInputView","commit_stats":{"total_commits":273,"total_committers":3,"mean_commits":91.0,"dds":0.03663003663003661,"last_synced_commit":"41c0fa13a9b556bf704a0db96b92ce7571c1f21f"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CRAnimation%2FCRBoxInputView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CRAnimation%2FCRBoxInputView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CRAnimation%2FCRBoxInputView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CRAnimation%2FCRBoxInputView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CRAnimation","download_url":"https://codeload.github.com/CRAnimation/CRBoxInputView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224369496,"owners_count":17299910,"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":["mobile","password","phone","phone-number","placeholder","uitextfield","uitextview","verifycode","verifycodeview"],"created_at":"2024-08-02T18:00:38.923Z","updated_at":"2024-11-13T00:30:24.979Z","avatar_url":"https://github.com/CRAnimation.png","language":"Objective-C","readme":"\u003ca id=\"Header_Start\"\u003e\u003c/a\u003e ![CRBoxInputViewHeadImg.png](/ReadmeResources/HeadImg.png \"CRBoxInputViewHeadImg.png\")\n[![CI Status](https://img.shields.io/travis/CRAnimation/CRBoxInputView.svg?style=flat)](https://travis-ci.org/CRAnimation/CRBoxInputView)\n[![Version](https://img.shields.io/cocoapods/v/CRBoxInputView.svg?style=flat)](https://cocoapods.org/pods/CRBoxInputView)\n[![License](https://img.shields.io/cocoapods/l/CRBoxInputView.svg?style=flat)](https://cocoapods.org/pods/CRBoxInputView)\n[![Platform](https://img.shields.io/cocoapods/p/CRBoxInputView.svg?style=flat)](https://cocoapods.org/pods/CRBoxInputView)\n\n### [中文文档](https://github.com/CRAnimation/CRBoxInputView#Header_Start) [/ English Document](https://github.com/CRAnimation/CRBoxInputView/blob/master/README_en.md#Header_Start)\n\n\n## Tip\n- 若图片加载不出来，请尝试开全局梯子\n- 如果好用，可以给个Star。您的支持是我最大的动力！\n- 建议使用前运行Demo。常用功能在Demo中都有体现。\n\n\n## 组件特点\n- 支持iOS12短信验证码自动填充\n- 支持`Masonry`\n- 支持密文显示\n- 支持自定义密文图片/view\n- 支持动态修改codeLength\n\n\u003e 该组件适用于短信验证码，密码输入框，手机号码输入框这些场景。\u003cbr/\u003e希望你可以喜欢！\n\n\n## Pod安装\n\nCRBoxInputView 可以通过 [CocoaPods](https://cocoapods.org). 来安装,  只需简单的在你的 Podfile 中添加如下代码:\n\n```ruby\npod 'CRBoxInputView', '1.2.1'\n```\n\n\n## 示列\n\n下载源代码后，可以从Example目录中执行 `pod install`，然后运行Demo。\n![iPhone 8 Copy 2.png](/ReadmeResources/ScreenShoot3.png \"iPhone 8 Copy 2.png\")\n\n\n## 快速指南\n| 类型  | 示例图片 |\n| :-------------: | :-------------: |\n| [Base](#Anchor_Base) | ![Normal.png](/ReadmeResources/1Normal.png \"Normal.png\")  |\n| [Placeholder](#Anchor_Placeholder) | ![Placeholder.png](/ReadmeResources/Add1_Placeholder0.png \"Placeholder.png\")  |\n| [CustomBox](#Anchor_CustomBox)  | ![CustomBox.png](/ReadmeResources/2CustomBox.png \"CustomBox.png\")  |\n| [Line](#Anchor_Line)  | ![Line.png](/ReadmeResources/3.1Line.png \"Line.png\")  |\n| [SecretSymbol](#Anchor_SecretSymbol)  | ![SecretSymbol.png](/ReadmeResources/4SecretSymbol.png \"SecretSymbol.png\")  |\n| [SecretImage](#Anchor_SecretImage)  | ![SecretImage.png](/ReadmeResources/5SecretImage.png \"SecretImage.png\")  |\n| [SecretView](#Anchor_SecretView)  | ![SecretView.png](/ReadmeResources/6SecretView.png \"SecretView.png\") |\n| [ResetCodeLength](#Anchor_ResetCodeLength)  | ![ResetCodeLength.png](/ReadmeResources/2ResetCodeLength.gif \"ResetCodeLength.png\")  |\n\n## 使用说明\n\n### \u003ca id=\"Anchor_Base\"\u003e\u003c/a\u003eBase\n![Normal.png](/ReadmeResources/1Normal.png \"Normal.png\")\n``` objc\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];\nboxInputView.codeLength = 4;// 不设置时，默认4\nboxInputView.keyBoardType = UIKeyboardTypeNumberPad;// 不设置时，默认UIKeyboardTypeNumberPad\n[boxInputView loadAndPrepareViewWithBeginEdit:YES]; // BeginEdit:是否自动启用编辑模式\n[self.view addSubview:boxInputView];\n\n// 输入类型（纯数字）\n_boxInputView.inputType = CRInputType_Number;\n\n// 输入类型（正则表达式）\n//_boxInputView.inputType = CRInputType_Regex;\n//_boxInputView.customInputRegex = @\"[^0-9]\";\n\n// 获取值\n// 方法1, 当输入文字变化时触发回调block\nboxInputView.textDidChangeblock = ^(NSString *text, BOOL isFinished) {\n    NSLog(@\"text:%@\", text);\n};\n// 方法2, 普通的只读属性\nNSLog(@\"textValue:%@\", boxInputView.textValue);\n\n// 清空\n[boxInputView clearAllWithBeginEdit:YES]; // BeginEdit:清空后是否自动启用编辑模式\n\n```\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_Placeholder\"\u003e\u003c/a\u003ePlaceholder\n![Placeholder.png](/ReadmeResources/Add1_Placeholder0.png \"Placeholder.png\")\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.cellPlaceholderTextColor = [UIColor colorWithRed:114/255.0 green:116/255.0 blue:124/255.0 alpha:0.3]; //可选\ncellProperty.cellPlaceholderFont = [UIFont systemFontOfSize:20]; //可选\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.ifNeedCursor = NO; //可选\nboxInputView.placeholderText = @\"露可娜娜\"; //必需\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:YES];\n```\n\u003e Ps:有一回，一个逗比队友，被对面娜可露露抓急了，口误喊成了“露可娜娜”。。。\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_CustomBox\"\u003e\u003c/a\u003eCustomBox\n![CustomBox.png](/ReadmeResources/2CustomBox.png \"CustomBox.png\")\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.cellBgColorNormal = color_FFECEC;\ncellProperty.cellBgColorSelected = [UIColor whiteColor];\ncellProperty.cellCursorColor = color_master;\ncellProperty.cellCursorWidth = 2;\ncellProperty.cellCursorHeight = 30;\ncellProperty.cornerRadius = 4;\ncellProperty.borderWidth = 0;\ncellProperty.cellFont = [UIFont boldSystemFontOfSize:24];\ncellProperty.cellTextColor = color_master;\ncellProperty.configCellShadowBlock = ^(CALayer * _Nonnull layer) {\n    layer.shadowColor = [color_master colorWithAlphaComponent:0.2].CGColor;\n    layer.shadowOpacity = 1;\n    layer.shadowOffset = CGSizeMake(0, 2);\n    layer.shadowRadius = 4;\n};\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.boxFlowLayout.itemSize = CGSizeMake(50, 50);\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:YES];\n```\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_Line\"\u003e\u003c/a\u003eLine\n![Line.png](/ReadmeResources/3.1Line.png \"Line.png\")\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.showLine = YES; //必需\ncellProperty.customLineViewBlock = ^CRLineView * _Nonnull{\n    CRLineView *lineView = [CRLineView new];\n    lineView.underlineColorNormal = [color_master colorWithAlphaComponent:0.3];\n    lineView.underlineColorSelected = [color_master colorWithAlphaComponent:0.7];\n    lineView.underlineColorFilled = color_master;\n    [lineView.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {\n        make.height.mas_equalTo(4);\n        make.left.right.bottom.offset(0);\n    }];\n\n    lineView.selectChangeBlock = ^(CRLineView * _Nonnull lineView, BOOL selected) {\n        if (selected) {\n            [lineView.lineView mas_updateConstraints:^(MASConstraintMaker *make) {\n                make.height.mas_equalTo(6);\n            }];\n        } else {\n            [lineView.lineView mas_updateConstraints:^(MASConstraintMaker *make) {\n                make.height.mas_equalTo(4);\n            }];\n        }\n    };\n    \n    return lineView;\n}; //可选\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:YES];\n```\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_SecretSymbol\"\u003e\u003c/a\u003eSecretSymbol\n![SecretSymbol.png](/ReadmeResources/4SecretSymbol.png \"SecretSymbol.png\")\n\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.securitySymbol = @\"*\"; //可选\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.ifNeedSecurity = YES; //必需（你可以在任何时候修改该属性，并且已经存在的文字会自动刷新。）\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:NO];\n\n_boxInputView.ifClearAllInBeginEditing = YES;\n[_boxInputView reloadInputString:@\"5678\"];\n```\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_SecretImage\"\u003e\u003c/a\u003eSecretImage\n![SecretImage.png](/ReadmeResources/5SecretImage.png \"SecretImage.png\")\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.securityType = CRBoxSecurityCustomViewType; //必需\ncellProperty.customSecurityViewBlock = ^UIView * _Nonnull{\n    CRSecrectImageView *secrectImageView = [CRSecrectImageView new];\n    secrectImageView.image = [UIImage imageNamed:@\"smallLock\"];\n    secrectImageView.imageWidth = 23;\n    secrectImageView.imageHeight = 27;\n    \n    return secrectImageView;\n}; //必需\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.ifNeedSecurity = YES; //必需（你可以在任何时候修改该属性，并且已经存在的文字会自动刷新。）\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:YES];\n```\n\n\n\u003cbr/\u003e\n\n### \u003ca id=\"Anchor_SecretView\"\u003e\u003c/a\u003eSecretView\n![SecretView.png](/ReadmeResources/6SecretView.png \"SecretView.png\")\n``` objc\nCRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];\ncellProperty.securityType = CRBoxSecurityCustomViewType; //必需\ncellProperty.customSecurityViewBlock = ^UIView * _Nonnull{\n    UIView *customSecurityView = [UIView new];\n    customSecurityView.backgroundColor = [UIColor clearColor];\n\n    // circleView\n    static CGFloat circleViewWidth = 20;\n    UIView *circleView = [UIView new];\n    circleView.backgroundColor = color_master;\n    circleView.layer.cornerRadius = 4;\n    [customSecurityView addSubview:circleView];\n    [circleView mas_makeConstraints:^(MASConstraintMaker *make) {\n        make.width.height.mas_equalTo(circleViewWidth);\n        make.centerX.offset(0);\n        make.centerY.offset(0);\n    }];\n\n    return customSecurityView;\n}; //可选\n\nCRBoxInputView *boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];\nboxInputView.ifNeedSecurity = YES; //必需（你可以在任何时候修改该属性，并且已经存在的文字会自动刷新。）\nboxInputView.customCellProperty = cellProperty;\n[boxInputView loadAndPrepareViewWithBeginEdit:YES];\n```\n\n\u003cbr/\u003e\n\n\n### \u003ca id=\"Anchor_ResetCodeLength\"\u003e\u003c/a\u003eResetCodeLength\n![ResetCodeLength.png](/ReadmeResources/2ResetCodeLength.gif \"ResetCodeLength.png\")\n``` objc\n[boxInputView resetCodeLength:_boxInputView.codeLength+1 beginEdit:YES];\n```\n\n\u003cbr/\u003e\n\n## 属性和方法\n`CRBoxInputCellProperty`\n``` objc\n#pragma mark - UI\n@property (assign, nonatomic) CGFloat borderWidth;\n@property (copy, nonatomic) UIColor *cellBorderColorNormal;\n@property (copy, nonatomic) UIColor *cellBorderColorSelected;\n@property (copy, nonatomic) UIColor *__nullable cellBorderColorFilled;\n@property (copy, nonatomic) UIColor *cellBgColorNormal;\n@property (copy, nonatomic) UIColor *cellBgColorSelected;\n@property (copy, nonatomic) UIColor *__nullable cellBgColorFilled;\n@property (assign, nonatomic) CGFloat cornerRadius;\n\n#pragma mark - cursor(光标)\n@property (copy, nonatomic) UIColor *cellCursorColor;\n@property (assign, nonatomic) CGFloat cellCursorWidth;\n@property (assign, nonatomic) CGFloat cellCursorHeight;\n\n#pragma mark - line\n@property (assign, nonatomic) BOOL showLine;\n\n#pragma mark - label\n@property (copy, nonatomic) UIFont *cellFont;\n@property (copy, nonatomic) UIColor *cellTextColor;\n\n#pragma mark - Security\n@property (assign, nonatomic) BOOL ifShowSecurity;\n@property (copy, nonatomic) NSString *securitySymbol;\n@property (assign, nonatomic) CRBoxSecurityType securityType;\n\n#pragma mark - Placeholder\n@property (copy, nonatomic) UIColor *cellPlaceholderTextColor;\n@property (copy, nonatomic) UIFont *cellPlaceholderFont;\n\n#pragma mark - Block\n/**\n自定义密文View回调\n*/\n@property (copy, nonatomic) CustomSecurityViewBlock customSecurityViewBlock;\n/**\n自定义下划线回调\n*/\n@property (copy, nonatomic) CustomLineViewBlock customLineViewBlock;\n/**\n自定义阴影回调\n*/\n@property (copy, nonatomic) ConfigCellShadowBlock __nullable configCellShadowBlock;\n```\n\n`CRBoxFlowLayout`\n``` objc\n@property (assign, nonatomic) BOOL ifNeedEqualGap;\n@property (assign, nonatomic) NSInteger itemNum;\n```\n\n`CRBoxInputView`\n``` objc\n// Security\n@property (assign, nonatomic) BOOL ifNeedSecurity;\n@property (assign, nonatomic) CGFloat securityDelay;\n\n@property (assign, nonatomic) BOOL ifNeedCursor;\n@property (nonatomic, assign) NSInteger codeLength;\n@property (assign, nonatomic) UIKeyboardType keyBoardType;\n@property (null_unspecified,nonatomic,copy) UITextContentType textContentType NS_AVAILABLE_IOS(10_0);\n@property (strong, nonatomic) NSString  * _Nullable placeholderText;\n@property (assign, nonatomic) BOOL ifClearAllInBeginEditing;\n\n@property (copy, nonatomic) TextDidChangeblock _Nullable textDidChangeblock;\n@property (copy, nonatomic) TextEditStatusChangeblock _Nullable textEditStatusChangeblock;\n@property (strong, nonatomic) CRBoxFlowLayout * _Nullable boxFlowLayout;\n@property (strong, nonatomic) CRBoxInputCellProperty * _Nullable customCellProperty;\n@property (strong, nonatomic, readonly) NSString  * _Nullable textValue;\n@property (strong, nonatomic) UIView * _Nullable inputAccessoryView;\n\n- (void)loadAndPrepareView;\n- (void)loadAndPrepareViewWithBeginEdit:(BOOL)beginEdit;\n- (void)reloadInputString:(NSString *_Nullable)value; // 重载输入的数据（用来设置预设数据）\n- (void)clearAll;\n- (void)clearAllWithBeginEdit:(BOOL)beginEdit;\n\n- (UICollectionView *_Nullable)mainCollectionView;\n- (void)quickSetSecuritySymbol:(NSString *_Nullable)securitySymbol;\n\n// 你可以在继承的子类中调用父类方法\n// You can inherit and call super\n- (void)initDefaultValue;\n- (UICollectionViewCell *_Nullable)customCollectionView:(UICollectionView *_Nullable)collectionView cellForItemAtIndexPath:(NSIndexPath *_Nullable)indexPath;\n```\n`CRBoxInputCell`\n``` objc\n// 你可以在继承的子类中重写父类方法\n// You can inherit and rewrite\n- (UIView *)createCustomSecurityView;\n```\n\n`CRLineView`\n``` objc\n@property (strong, nonatomic) UIView    *lineView;\n\n@property (copy, nonatomic) UIColor *underlineColorNormal;\n@property (copy, nonatomic) UIColor *underlineColorSelected;\n@property (copy, nonatomic) UIColor *underlineColorFilled;\n```\n\n## 其他问题\n\n- [pod search 搜索不到库（已解决）](https://github.com/CRAnimation/CRBoxInputView/issues/1 \"pod search 搜索不到库\")\n- [pod 安装失败， [!] Unable to find a specification for CRBoxInputView（已解决）](https://github.com/CRAnimation/CRBoxInputView/issues/2 \"pod 安装失败， [!] Unable to find a specification for CRBoxInputView\")\n\n## 作者\n\nBearRan, 648070256@qq.com\n\n## 反馈\n如果你在使用这个控件时遇到了问题，可以通过E-mail告诉我，或者为此开一个issuse。\n\n## License\n\nCRBoxInputView is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["UI Components","OOM-Leaks-Crash"],"sub_categories":["CodeUnit-AuthenticationCode"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCRAnimation%2FCRBoxInputView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCRAnimation%2FCRBoxInputView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCRAnimation%2FCRBoxInputView/lists"}