iOS开发 - 二维码的扫描

= self.scanView.frame.origin.y; CGFloat scanImageViewW = self.scanViewWidth.constant; CGFloat scanImageViewH = 7; _scanImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scanLine"]]; _scanImageView.frame = CGRectMake(scanImageViewX, scanImageViewY, scanImageViewW, scanImageViewH); [self.scanView addSubview:_scanImageView]; [UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionRepeat animations:^{ _scanImageView.frame = CGRectMake(scanImageViewX, scanImageViewY + self.scanViewHeight.constant, scanImageViewW, scanImageViewH); } completion:nil];}

四、具体代码

  • 设备,输入源和输出源的懒加载

    /***  懒加载设备*/-(AVCaptureDevice *)device {  if (!_device) {      _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];  }  return _device;}