- - (void)viewDidLoad {
- [super viewDidLoad];
- //扫描有效区(即框内透明区域)CGRect interestRect = CGRectMake(20, (self.view.frame.size.height - (self.view.frame.size.width -40))/2.0f, self.view.frame.size.width -40, self.view.frame.size.width -40);
- //扫描控件_scanView = [[LFQRCodeScanner alloc] initWithFrame:self.view.bounds rectOfInterest:interestRect];
- _scanView.imgLine.image = [UIImage imageNamed:@"line"];
- _scanView.scanFilishBlock = ^(AVMetadataMachineReadableCodeObject *result) {
- NSLog(@"扫描结果:%@",result.stringValue);
- };
- [self.view insertSubview:_scanView atIndex:0];//将扫描view放到底层
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear: animated];
- [self.scanView start];
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear: animated];
- [self.scanView stop];
- }
来源: http://www.bubuko.com/infodetail-2075419.html