Skip to content

Instantly share code, notes, and snippets.

@dbaldwin
Created July 16, 2012 18:30
Show Gist options
  • Save dbaldwin/3124186 to your computer and use it in GitHub Desktop.
Save dbaldwin/3124186 to your computer and use it in GitHub Desktop.
Display barcode scanning rectangle area in overlay with RedLaser SDK
- (void)viewDidLoad
{
[super viewDidLoad];
// Create rectangle layer and add it to view
rectLayer = [CAShapeLayer layer];
rectLayer.fillColor = [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2] CGColor];
rectLayer.strokeColor = [[UIColor whiteColor] CGColor];
rectLayer.lineWidth = 3;
[self.view.layer addSublayer:rectLayer];
}
- (void) viewWillAppear:(BOOL)animated
{
// Draw and display rectangle
CGMutablePathRef path = CGPathCreateMutable();
CGRect activeRegionRect = CGRectMake(0, 100, 320, 250);
CGPathAddRect(path, NULL, activeRegionRect);
[rectLayer setPath: path];
CGPathRelease(path);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment