iOS应用程序内的条形码生成

Ray*_*ond 30 iphone barcode ipad ios

我想取一个数字字符串并生成一个简单的条形码,任何扫描仪都可以读取.

我已经可以使用相机并读取条形码,但现在我想生成一个条形码.

有谁知道一个允许我这样做,资源或代码snipets的sdk?

谢谢

Jan*_*ano 31

唯一可以做到这一点的免费图书馆是Cocoa-Touch- Barcodes,这是一个cocoabarcodes的分支.如果你正在考虑商业图书馆,有一个名为iPhone条形码生成器.

更新检查ZXing的这个objective-c端口:https://github.com/TheLevelUp/ZXingObjC


小智 15

包括:#import "NKDBarcodeFramework.h"在你的头文件中,并将这些行放在你的init函数中.

barcode = [NKDExtendedCode39Barcode alloc];
barcode = [barcode initWithContent:@"1234567890123" printsCaption:0];

[barcode calculateWidth];
NSLog(@"%@",[barcode description]);

theImage = [UIImage imageFromBarcode:barcode];
subview = [[UIImageView alloc]initWithFrame:TTScreenBounds()];
[subview setImage:theImage]; 
[self addSubview:subview];

self.frame = self.bounds;
Run Code Online (Sandbox Code Playgroud)

玩得开心 :-)


Dur*_*n.H 7

有很多条形码类型

  • 一个D.
  • 两个D.
  • 三个D.

每种条形码类型都有很多子类型,每种都有自己的用途.

我解释了如何生成One D条形码类型代码39之一

在这里,我解释如何使用自定义字体生成该条形码

脚步:

1)从这里下载自定义字体

2)从下载的zip中附加文件FRE3OF9X.ttf

3)加密钥由应用程序提供的字体中的info.plist和在项0FRE3OF9X.ttf作为值

4)尝试以下代码段

UIFont *fntCode39=[UIFont fontWithName:@"Free3of9Extended" size:30.0];

UILabel *lblBarCodeTest=[[UILabel alloc]initWithFrame:CGRectMake(0,100,768,30)];

[lblBarCodeTest setBackgroundColor:[UIColor lightGrayColor]];

[lblBarCodeTest setTextAlignment:NSTextAlignmentCenter];

[lblBarCodeTest setFont:fntCode39];

[lblBarCodeTest setText:@"*BarCode3Of9_AKA_Code39-ItsA1DBarcode*"];

[self.view addSubview:lblBarCodeTest];
Run Code Online (Sandbox Code Playgroud)

结果:

条码


And*_*nov 6

您可以使用CoreImage生成条形码图像.CoreImage包含4个生成不同条形码的过滤器:CICode128BarcodeGenerator,CIQRCodeGenerator,CIPDF417BarcodeGenerator,CIAztecCodeGenerator.