1

I want to generate a barcode on some UIImage or UIImageView. Is it possible.I am using This for generating the barcode.

Please help me. Thanks

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
ios developer
  • 3,363
  • 3
  • 51
  • 111

3 Answers3

2

Another option would be to use the URL of an online barcode generator as the source for a UIImage. For example:

NSString *barCodeValue = @"0123456789";
NSString *barCodeURL = [NSString stringWithFormat:@"http://www.barcodesinc.com/generator/image.php?code=%@&style=197&type=C128B&width=200&height=100&xres=1&font=3", barCodeValue];
barCodeImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:barCodeURL]]];
1

I am not sure but you can give a try :

1) Convert UIImage into Base64 String.

2) Now, you use this string to generate barcode.

[barcode setupQRCode:base64String];

Hope it helps you...

Maulik
  • 19,348
  • 14
  • 82
  • 137
0

if BarCode generated on UIView like component you can take screen shot of this view and get the image from this view hope this help you

-(UIImage *)getFinalImageAndBarCodeView:(UIView*)view{
////Create a new render context of the UIView size, and set a scale so that the full stage will render to it.
UIGraphicsBeginImageContext(CGSizeMake(view.bounds.size.width, view.bounds.size.height));
CGContextScaleCTM(UIGraphicsGetCurrentContext(),1.0f,1.0f);

//Render the stage to the new context
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

// Get an image from the context
UIImage* viewImage=0;
viewImage=UIGraphicsGetImageFromCurrentImageContext();

// Kill the render context
UIGraphicsEndImageContext();

return viewImage;

}

SachinVsSachin
  • 6,401
  • 3
  • 33
  • 39