从 iOS 应用程序内生成条形码
我想获取一个数字字符串并生成一个可以由任何扫描仪读取的简单条形码。
我已经可以使用相机并读取条形码,但现在我想生成条形码。
有谁知道可以让我执行此操作的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
唯一可以执行此操作的免费库是 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
在头文件中包含:
#import "NKDBarcodeFramework.h"
并将这些行放在 init 函数的下面。玩得开心 :-)
Include :
#import "NKDBarcodeFramework.h"
in your Header File and put these lines below in your init function.have fun :-)
条形码类型有很多种
每种条形码类型都有很多子类型,并且每种都有其自己的用途。
我在这里解释如何生成 One D 条形码类型代码 39 之一,
我解释如何使用自定义字体生成该条形码
步骤:
1) 从 此处
2) 从下载的 zip 中附加文件 FRE3OF9X.ttf
3) 添加密钥应用程序提供的字体item 0 中将 FRE3OF9X.ttf 作为值
4) 尝试以下代码片段
结果:
There are so many barcode types
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
Result:
您可以使用 CoreImage 生成条形码图像。 CoreImage 包含 4 个过滤器来生成不同的条形码: CICode128BarcodeGenerator, CIQRCodeGenerator,<一个href="https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIPDF417BarcodeGenerator" rel="noreferrer">CIPDF417BarcodeGenerator,<一个href="https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIAztecCodeGenerator" rel="noreferrer">CIAztecCodeGenerator。
You can use CoreImage to generate Barcode images. CoreImage contains 4 filters to generate different barcodes: CICode128BarcodeGenerator, CIQRCodeGenerator, CIPDF417BarcodeGenerator, CIAztecCodeGenerator.
我创建了一个简单的类来生成 Code 39 条形码,只需将一个 .h 和一个 .m 添加到您的项目中,并且只需一行代码即可为您生成包含 Code 39 编码数据的 UIImage,如下所示
: 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:
Here's the link to the project on github:
[https://github.com/bclin087/Simple-Code39-generator-for-iOS.git ]