iOS 實現微信掃一掃樣式

jopen 9年前發布 | 53K 次閱讀 IOS 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];

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!