Skip to content

Instantly share code, notes, and snippets.

@taylanpince
Created April 17, 2012 10:25
Show Gist options
  • Save taylanpince/2405109 to your computer and use it in GitHub Desktop.
Save taylanpince/2405109 to your computer and use it in GitHub Desktop.
ZBar Integration
ZBarReaderViewController *controller = [ZBarReaderViewController new];
[controller setReaderDelegate:self];
[controller.scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 80.0)];
UILabel *helpLabel = [[UILabel alloc] initWithFrame:CGRectInset(overlayView.bounds, 15.0, 10.0)];
[helpLabel setFont:[UIFont boldSystemFontOfSize:14.0]];
[helpLabel setTextColor:[UIColor whiteColor]];
[helpLabel setTextAlignment:UITextAlignmentCenter];
[helpLabel setNumberOfLines:0];
[helpLabel setLineBreakMode:UILineBreakModeWordWrap];
[helpLabel setBackgroundColor:[UIColor clearColor]];
[helpLabel setText:NSLocalizedString(@"Align your camera at about 3 to 5 \
inches from a barcode and hold still. \
Scanner will automatically detect it.", nil)];
[overlayView addSubview:helpLabel];
[overlayView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.6]];
[controller setCameraOverlayView:overlayView];
[overlayView release];
[helpLabel release];
[self presentModalViewController:controller animated:YES];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment