Skip to content

li125434104/XJScanQRCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XJScanQRCode

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

XJScanQRCode is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XJScanQRCode'

How to user

//输出流视图
    UIView *preview  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:preview];
    
    self.scanView = [[XJScanView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:self.scanView];
    [self.scanView showFlashSwitch:YES];
    
    __weak typeof(self) weakSelf = self;
    
    self.scanTool = [[XJScanTools alloc] initWithPreview:preview andScanFrame:self.scanView.scanSweepAreaRect];
    [self.scanTool sessionStartRunning];
    self.scanTool.scanFinishedBlock = ^(NSString *scanString) {
        NSLog(@"扫描结果:%@",scanString);
        [weakSelf.scanView handlingResultsOfScan];
        [weakSelf.scanTool sessionStopRunning];
        
    };
    self.scanTool.monitorLightBlock = ^(float brightness) {
        NSLog(@"环境光感 : %f",brightness);
        if (brightness < 0) {
            // 环境太暗,显示闪光灯开关按钮
            [weakSelf.scanView showFlashSwitch:YES];
        }else if(brightness > 0){
            // 环境亮度可以,且闪光灯处于关闭状态时,隐藏闪光灯开关
            if(!weakSelf.scanTool.flashOpen){
                [weakSelf.scanView showFlashSwitch:NO];
            }
        }
    };

Author

li125434104, [email protected]

License

XJScanQRCode is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published