类似于极验验证码
如果对你有帮助,请亮个 star!
1,支持本地图片作为验证码模板,无需后台支持
2,支持网络图片作为验证码模版(只需一个URL)
3,可统计验证成功、失败次数(自己计数)
4,不依赖于其他平台闭源SDK、framework
创建:
- 本地图片验证
//native image to detect
CGSize size = self.view.bounds.size;
UIImage *img__ = [UIImage imageNamed:@"test_4.jpg"];
NHGraphCoder *coder = [NHGraphCoder codeWithImage:img__];
coder.center = CGPointMake(size.width*0.5, size.height*0.5);
[coder handleGraphicCoderVerifyEvent:^(NHGraphCoder * _Nonnull cd, BOOL success) {
NSLog(@"验证结果:%d",success);
}];
[self.view addSubview:coder];
- 网络图片验证
//network image to detect
NSString *url = @"http://pic.pimg.tw/loloto/1357207442-1350656755_l.jpg?v=1357207447";
NHGraphCoder *coder = [NHGraphCoder codeWithURL:url];
coder.center = CGPointMake(size.width*0.5, size.height*0.5);
[coder handleGraphicCoderVerifyEvent:^(NHGraphCoder * _Nonnull cd, BOOL success) {
NSLog(@"验证结果:%d",success);
}];
[self.view addSubview:coder];
刷新图形:
[coder resetStateForDetect];