我想在一些UIImage或UIImageView上生成条形码。有没有可能。我正在使用This生成条形码。
请帮帮我。谢谢
发布于 2012-10-31 20:01:18
另一种选择是使用在线条形码生成器的URL作为UIImage的源。例如:
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]]];发布于 2012-10-31 19:17:31
我不确定,但你可以试一试:
1)将UIImage转换为Base64 String.
2)现在,使用该字符串生成条形码。
[barcode setupQRCode:base64String];
希望它能帮到你。
发布于 2012-10-31 19:20:46
如果在类似UIView的组件上生成BarCode,您可以截取此视图的屏幕截图并从中获取图像,希望这能对您有所帮助
-(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;}
https://stackoverflow.com/questions/13156276
复制相似问题