XMVerificationCodeInputView
示例
使用
一个简单验证码输入框 可以自定义颜色 字体等 支持自动布局
现默认有两种type 一种是下划线 一种是矩形
可以自定义输入框样式 需继承于XMBaseInputBox 具体参考Example里的XMRhombusInputBox类
//下划线类型
XMVerificationCodeInputView *underLineView = [[XMVerificationCodeInputView alloc] initWithFrame:CGRectMake(50, 100, self.view.bounds.size.width-100, 50)];
//输入框个数 默认为4
underLineView.textCount = 6;
underLineView.boxType = XMVerificationCodeInputViewUnderline;
[self.view addSubview:underLineView];
underLineView.textDidInputComplete = ^(NSString * _Nonnull text) {
[weakself showAlertWithText:text];
} ;
//矩形带边框类型
XMVerificationCodeInputView *retangleInputView = [[XMVerificationCodeInputView alloc] initWithFrame:CGRectMake(50, CGRectGetMaxY(underLineView.frame)+50, self.view.bounds.size.width-100, 40)];
retangleInputView.textCount = 5;
retangleInputView.boxType = XMVerificationCodeInputViewRetangle;
[self.view addSubview:retangleInputView];
retangleInputView.textDidInputComplete = ^(NSString * _Nonnull text) {
[weakself showAlertWithText:text];
} ;
//自定义类型
XMVerificationCodeInputView *customInputView = [[XMVerificationCodeInputView alloc] initWithFrame:CGRectMake(50, CGRectGetMaxY(squareInputView.frame)+50, self.view.bounds.size.width-100, 50)];
customInputView.boxType = XMVerificationCodeInputViewCustom;
customInputView.customInputBox = [XMRhombusInputBox class];
[self.view addSubview:customInputView];
customInputView.textDidInputComplete = ^(NSString * _Nonnull text) {
[weakself showAlertWithText:text];
} ;
安装
XMVerificationCodeInputView 可通过 CocoaPods 获取。安装方法很简单,只需将以下行添加到 Podfile 中
pod 'XMVerificationCodeInputView'
作者
许可证
XMVerificationCodeInputView 适用于MIT许可证。有关更多信息,请参阅LICENSE文件。