CDCodabarView is a Codabar barcode generator for iOS.
It is written in Swift 5 and uses IBDesignable
, IBInspectable
and Core Graphics.
Add https://github.com/Coledunsby/CDCodabarView
as a package dependency.
CDCodabarView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CDCodabarView'
Copy CDCodabarView.swift
and CDCodabarEncoder.swift
into your project.
- Drag a UIView into your storyboard.
- Change the class of the UIView to
CDCodabarView
. - Customize your barcode using the inspector.
-
Import the module:
import CDCodabarView
-
Initialize an instance of
CDCodabarView
using the constructor:let codabarView = CDCodabarView() codabarView.frame = CGRect(x: 0, y: 0, width: 200, height: 100) codabarView.code = "A12345B" codabarView.backgroundColor = .white
-
Customize the barcode:
codabarView.barColor = .blue codabarView.textColor = .red codabarView.padding = 5 codabarView.hideCode = false codabarView.font = UIFont(name: "AvenirNext-Regular", size: 15.0)!
-
Add the barcode to your view:
view.addSubview(codabarView)
See the example project for more usage examples.
Cole Dunsby, [email protected]
CDCodabarView is available under the MIT license. See the LICENSE file for more info.