IOS抖音短视频APP开发关于扫描二维码,(根据光线强弱显示隐藏闪光灯)并根据文本生成二维码。
WeakSelf;
//IOS抖音短视频APP开发构建扫描样式视图
_scanView = [[WSLScanView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 0)];
_scanView.scanRetangleRect = CGRectMake(60, 120, (self.view.frame.size.width - 2 * 60), (self.view.frame.size.width - 2 * 60));
_scanView.colorAngle = [UIColor whiteColor];
_scanView.photoframeAngleW = 20;
_scanView.photoframeAngleH = 20;
_scanView.photoframeLineW = 1;
_scanView.isNeedShowRetangle = YES;
_scanView.colorRetangleLine = [UIColor clearColor];
_scanView.notRecoginitonArea = [UIColor clearColor];
_scanView.animationImage = [UIImage imageNamed:@"scanLine"];
_scanView.myQRCodeBlock = ^{
mineCodeMaViewController *vc = [[mineCodeMaViewController alloc]init];
[weakSelf.navigationController pushViewController:vc animated:YES];;
_scanView.flashSwitchBlock = ^(BOOL open) {
[weakSelf.scanTool openFlashSwitch:open];
[self.view addSubview:_scanView];
//IOS抖音短视频APP开发初始化扫描工具
_scanTool = [[WSLNativeScanTool alloc] initWithPreview:preview andScanFrame:_scanView.scanRetangleRect];
_scanTool.scanFinishedBlock = ^(NSString *scanString) {
NSLog(@"扫描结果 %@",scanString);
[weakSelf.scanView handlingResultsOfScan];
if ([scanString isEqual:[Config getOwnID]]) {
[MBProgressHUD showError:YZMsg(@"别扫自己了")];
[weakSelf.scanTool sessionStopRunning];
[weakSelf.scanTool openFlashSwitch:NO];
return ;
[YBToolClass postNetworkWithUrl:@"User.GetUserHome" andParameter:@{@"liveuid":scanString} success:^(int code, id _Nonnull info, NSString * _Nonnull msg) {
if (code == 0) {
NSDictionary *subDic = [info firstObject];
userCenterViewController *vc = [[userCenterViewController alloc]init];
vc.touserID = scanString;
vc.userMsg = subDic;
[[MXBADelegate sharedAppDelegate] pushViewController:vc animated:YES];
}else{
[MBProgressHUD showError:msg];
} fail:^{
[weakSelf.scanTool sessionStopRunning];
[weakSelf.scanTool openFlashSwitch:NO];
//IOS抖音短视频APP开发光感显示隐藏闪光灯
_scanTool.monitorLightBlock = ^(float brightness) {
NSLog(@"环境光感 : %f",brightness);
if (brightness < 0) {
// IOS抖音短视频APP开发环境太暗,显示闪光灯开关按钮
[weakSelf.scanView showFlashSwitch:YES];
}else if(brightness > 0){
//IOS抖音短视频APP开发环境亮度可以,且闪光灯处于关闭状态时,隐藏闪光灯开关
if(!weakSelf.scanTool.flashOpen){
[weakSelf.scanView showFlashSwitch:NO];
//IOS抖音短视频APP开发开始扫码
[_scanTool sessionStartRunning];
[_scanView startScanAnimation];
//IOS抖音短视频APP开发生成二维码
[WSLNativeScanTool createQRCodeImageWithString:[Config getOwnID] andSize:CGSizeMake(250, 250) andBackColor:[UIColor whiteColor] andFrontColor:[UIColor blackColor] andCenterImage:headerIcon];
WSLScanView下载链接
IOS抖音短视频APP开发是在利用原生API的条件下封装的二维码扫描工具,支持二维码的扫描、识别图中二维码、生成自定义颜色和中心图标的二维码、监测环境亮度、打开闪光灯这些功能。
声明:本篇文章为小编原创文章,转载请注明出处(带连接)及作者。