将矩形添加为相机视图上的叠加层。代码如下:
- (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;
}
希望对你有帮助..:)