BarCodeReaderView is a swift class that inherits from UIView
which can read Barcodes.
The prefered way to integrate BarCodeReaderView
is through cocoapods.
Add pod 'BarCodeReaderView'
to your Podfile.
first thing you need to import it
import BarCodeReaderView
Then you can either hook it through InterfaceBuilder, or using code as follows:
let barcodeReader = BarcodeReaderView(frame: CGRect(x: 20.0, y: 20.0, width: 200, height: 200))
self.view.addSubview(barcodeReader)
after that you just set the delegate and barcode types:
barcodeReader.delegate = self
barcodeReader.barCodeTypes = [.Code128]
for supported barcode types see supported barcode types section
delegate should implement two methods:
func barcodeReader(barcodeReader: BarcodeReaderView, didFailReadingWithError error: NSError) {
// handle error
}
func barcodeReader(barcodeReader: BarcodeReaderView, didFinishReadingString info: String) {
//handle success reading
}
once every thing ready, you call
barcodeReader.startCapturing()
and you can stop capturing by calling
barcodeReader.stopCapturing()
Aztec
Code128
PDF417Barcode
QR
UPCECode
Code39Code
Code39Mod43Code
EAN13Code
EAN8Code
Interleaved2of5Code
ITF14Code
DataMatrixCode
BarCodeReaderView is available under the MIT license.
Omar Alshammari