typedef NS_ENUM(NSUInteger,WSQIdentifyingCodeType){
DefaultType = 0, // 默认数字、字母、中文混合
CountType = 1 // 加法
};
/* 返回结果*/
typedef void(^resultBackBlock)(NSString * backString);
@interface WSQIdentifyingView :UIView
/**
* 初始化大小与类型
*
* param frame 大小
* param type 类型
*/
- (instancetype)initWithFrame:(CGRect)frame WithType:(WSQIdentifyingCodeType)type;
/**
* 获取当前页面上显示的字母或计算的值
*
* param block 传值
*/
- (void)getResultString:(resultBackBlock)result;
-(void)getResultString:(resultBackBlock)result{
resultBlock = result;
}
- (instancetype)initWithFrame:(CGRect)frame WithType:(WSQIdentifyingCodeType)type
{
if (self = [superinitWithFrame:frame]) {
self.layer.cornerRadius =5.0; //设置layer圆角半径
self.layer.masksToBounds =YES;
self.backgroundColor =kRandomColor;
if (type ==DefaultType) {
[selfchangeCaptcha];
}elseif (type == CountType){
[selfchangeCount];
}
_CodeType = type;
}
returnself;
}
更多完整详细dome:http://download.csdn.net/download/qq_33646395/9987338