iOS 实现微信扫一扫样式

分享到:

-(void)loopDrawLine

{

   CGRect  rect= CGRectMake(0,50, 320, 2);

   if (readLineView) {

    [readLineView removeFromSuperview];

  }

   readLineView = [[UIImageView alloc]initWithFrame:rect];

   readLineView.backgroundColor =[UIColor redColor];

    [UIViewanimateWithDuration:3.0

               delay: 0.0

              options:UIViewAnimationOptionCurveEaseIn

             animations:^{

//修改fream的代码写在这里

               readLineView.frame =CGRectMake(0, 300,320, 2);

               [readLineView setAnimationRepeatCount:0];

               

             }

             completion:^(BOOL finished){

               if(!is_Anmotion) {

                [self loopDrawLine]; 

               }

               

             }];

     

    if (!is_have) {

       UIImage *hbImage=[UIImage imageNamed:@"DecodeFrameForeground.png"];

       UIImageView *hbImageview=[[UIImageView alloc] initWithImage:hbImage];

       //添加一个背景图片

       CGRect hbImagerect=CGRectMake(0, 0,320, 435);

      [hbImageview setFrame:hbImagerect];

       

      ZBarReaderView *readview = [ZBarReaderView new];

      readview.backgroundColor= [UIColor clearColor];

      readview.frame= CGRectMake(0, 0, 320, 380);

       readview.readerDelegate = self;

       readview.allowsPinchZoom = YES;//使用手势变焦

      readview.trackingColor =[UIColor redColor];

      readview.showsFPS = YES;//显示帧率 YES 显示 NO不显示

      readview.scanCrop = CGRectMake(0, 0,1, 1);//将被扫描的图像的区域

      [readview addSubview:hbImageview];

      [readview addSubview:readLineView];

      [self.view addSubview:readview];

      [readview start];

       is_have = YES;

    }

    [self.view addSubview:readLineView];

}

根据实际情况 自己设置参数 ,需要注意的是 扫描到数据后一定要记得: [readerViewstop];

[readerViewremoveFromSuperview];

昵    称:
验证码:

相关文档: