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

发布于 2024-11-02 22:18:35 字数 124 浏览 2 评论 0原文

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

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

有谁知道可以让我执行此操作的 SDK、资源或代码片段吗?

谢谢

I want to take a numerical string and generate a simple barcode that can be read by any scanner.

I can already use the camera and read a barcode but now I would like to generate a barcode.

Does anyone know of an sdk that will allow me to do this, resources or code snipets?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

眼藏柔 2024-11-09 22:18:35

唯一可以执行此操作的免费库是 Cocoa-Touch-Barcodes,它是cocoabarcodes。如果您正在考虑商业图书馆,有一个名为 iPhone 条形码生成器

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

The only free library to do this is Cocoa-Touch-Barcodes, which is a fork of cocoabarcodes. If you are considering commercial libraries, there is one called iPhone Barcode Generator.

update Check this objective-c port of ZXing: https://github.com/TheLevelUp/ZXingObjC

痴情 2024-11-09 22:18:35

在头文件中包含:#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;

玩得开心 :-)

Include : #import "NKDBarcodeFramework.h" in your Header File and put these lines below in your init function.

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;

have fun :-)

倾听心声的旋律 2024-11-09 22:18:35

条形码类型有很多种

  • 一 D
  • 二 D
  • 三 D

每种条形码类型都有很多子类型,并且每种都有其自己的用途。

我在这里解释如何生成 One D 条形码类型代码 39 之一,

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

步骤:

1) 从 此处

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

3) 添加密钥应用程序提供的字体item 0 中将 FRE3OF9X.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];

结果:

条形码

There are so many barcode types

  • One D
  • Two D
  • Three D

Each barcode type has so many subtypes and each has its own purpose.

I explain how to generate one of the One D barcode type code 39

here i explain how to generate that barcode using Custom font

Steps:

1)Download the custom font from here

2)Attach the file FRE3OF9X.ttf from the downloaded zip

3)add the key Fonts provided by application in info.plist and in item 0 give FRE3OF9X.ttf as value

4)Try the below code snippet

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];

Result:

Barcode

寂寞陪衬 2024-11-09 22:18:35

我创建了一个简单的类来生成 Code 39 条形码,只需将一个 .h 和一个 .m 添加到您的项目中,并且只需一行代码即可为您生成包含 Code 39 编码数据的 UIImage,如下所示

UIImage *code39Image = [Code39 code39ImageFromString:@"HELLO CODE39" Width:barcode_width Height:barcode_height];

: github上的项目链接:
[https://github.com/bclin087/Simple-Code39-generator- for-iOS.git]

I've created a simple class for generating Code 39 Barcode, only one .h and one .m needed to add to your project, and with one line of code it generates the UIImage with code 39 encoded data for you, like this:

UIImage *code39Image = [Code39 code39ImageFromString:@"HELLO CODE39" Width:barcode_width Height:barcode_height];

Here's the link to the project on github:
[https://github.com/bclin087/Simple-Code39-generator-for-iOS.git ]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文