1

我们如何将矩形带入相机进行条码扫描,如带有扫描范围的红色激光?是否有任何内置属性?我尝试了以下操作:

 reader.readerView.tracksSymbols = YES;
reader.readerView.trackingColor = [UIColor redColor];

[reader setShowsZBarControls:NO];
reader.readerView.tracksSymbols = TRUE;
scanner.accessibilityFrame = CGRectMake(100, 100, 200, 300);
4

2 回答 2

2

将矩形添加为相机视图上的叠加层。代码如下:

- (IBAction) scanButtonTapped
    {
        // ADD: present a barcode reader that scans from the camera feed
        ZBarReaderViewController *reader = [ZBarReaderViewController new];
        reader.readerDelegate = self;
        reader.supportedOrientationsMask = ZBarOrientationMaskAll;

        ZBarImageScanner *scanner = reader.scanner;
        reader.showsZBarControls = NO;

        [scanner setSymbology: ZBAR_I25
                       config: ZBAR_CFG_ENABLE
                           to: 0];
        // present and release the controller
        [self presentModalViewController: reader
                                animated: YES];
        reader.cameraOverlayView = [self CommomOverlay];
        [reader release];
    }


-(UIView*)CommomOverlay{  
        UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
       UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(70,160,203,180)];
        [FrameImg setImage:[UIImage imageNamed:@"overlaygraphic.png"]];
       [view addSubview:FrameImg];
        return view;
    }

希望对你有帮助..:)

于 2012-06-15T07:26:07.970 回答
0

你试过了吗

 reader.cameraOverlayView = overLayView;

?? 即cameraOverlayView的财产UIImagePickerController。在那里你可以设置任何你想要的。希望这是你想要的。

于 2012-06-15T06:46:11.437 回答