Barcode128View
示例
要运行示例项目,请克隆仓库,并首先从示例目录中运行 pod install
。
需求
安装
Barcode128View 通过 CocoaPods 提供。安装它,只需在您的Podfile中添加以下行:
pod "Barcode128View"
用法
首先将一个 UIView 添加到您的 UIViewController 中,并将其类设置为如图所示的 Barcode128View。 素材设置

然后,只需在属性检查器中设置所有属性,视图将自动更新其内容。
如果您想手动设置 Barcode128View 的属性,可以在代码中连接视图 代码设置
@IBOutlet weak var codeView: Barcode128View!
然后,设置属性
codeView.code128String = "0123456789"
/* optionnal */
codeView.font = UIFont.systemFont(ofSize: 20)
codeView.barColor = UIColor.black
codeView.textColor = UIColor.darkGray
codeView.showCode = true
codeView.padding = 0
您可以通过 init(frame:) 方法手动创建 Barcode128View 并设置所有属性 手动设置
let codeView = Barcode128View(frame: frame)
或者在 init(frame:) 方法的参数中添加想要的属性来使用自定义的初始化方法
let secondCodeView = Barcode128View(frame: CGRect(x: 0, y: 0, width: 250, height: 150),
code128String: "012345678999",
/* optionnal */
barColor: .black,
textColor: .darkGray,
padding: 0,
showCode: true,
fontName: "Helvetica",
fontSize: 30
//or font: UIFont.systemFontOfSize(30)
)
view.addSubview(secondCodeView)
特性
open var code128String: String! // default ""
open var barColor: UIColor! // default .black
open var textColor: UIColor! // default .black
open var padding: CGFloat! // default 0
open var showCode: Bool! // default false
open var fontName: String! // default "System"
open var fontSize: CGFloat! // default 16
open var font: UIFont! // default UIFont.systemFont(ofSize: 16)
作者
zimmer
许可
Barcode128View 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。