- Notifications
You must be signed in to change notification settings - Fork1
satyadevchauhan/CodeGeneratorAndScanner
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Using the CoreImage framework, one can easily generate Bar/QR Codes within an iOS app with very few lines of code. Using the CoreImage filter, specifically the 'CICode128BarcodeGenerator' for Bar code and ‘CIQRCodeGenerator‘ for QR Code filter, we can get a CIImage that can be convert to UIImage for usage. Please visitCore Image Filter Reference for more information.
Following are supportedCICategoryGenerator:
- CIAztecCodeGenerator
- CICheckerboardGenerator
- CICode128BarcodeGenerator
- CIConstantColorGenerator
- CILenticularHaloGenerator
- CIPDF417BarcodeGenerator
- CIQRCodeGenerator
- CIRandomGenerator
- CIStarShineGenerator
- CIStripesGenerator
- CISunbeamsGenerator
func generateBarCode(_ string:String)->UIImage{if !string.isEmpty{letdata= string.data(using:String.Encoding.ascii)letfilter=CIFilter(name:"CICode128BarcodeGenerator") // Check the KVC for the selected code generator filter.setValue(data, forKey:"inputMessage")lettransform=CGAffineTransform(scaleX:10, y:10)letoutput= filter.outputImage?.transformed(by: transform)returnUIImage(ciImage: output!)}else{returnUIImage()}}
func generateQRCode(_ string:String)->UIImage{if !string.isEmpty{letdata= string.data(using:String.Encoding.ascii)letfilter=CIFilter(name:"CIQRCodeGenerator") // Check the KVC for the selected code generator filter.setValue(data, forKey:"inputMessage")lettransform=CGAffineTransform(scaleX:10, y:10)letoutput= filter.outputImage?.transformed(by: transform)returnUIImage(ciImage: output!)}else{returnUIImage()}}
Using AVFoundation framework we can scan all kinds of market leading bar code formats. Please visitAVMetadataObject.ObjectType for all supported formats on iOS.
Following are supported scanning formats:
- AVMetadataObject.ObjectType.aztec
- AVMetadataObject.ObjectType.code128
- AVMetadataObject.ObjectType.code39
- AVMetadataObject.ObjectType.code39Mod43
- AVMetadataObject.ObjectType.code93
- AVMetadataObject.ObjectType.dataMatrix
- AVMetadataObject.ObjectType.ean13
- AVMetadataObject.ObjectType.ean8
- AVMetadataObject.ObjectType.face
- AVMetadataObject.ObjectType.interleaved2of5
- AVMetadataObject.ObjectType.itf14
- AVMetadataObject.ObjectType.pdf417
- AVMetadataObject.ObjectType.qr
- AVMetadataObject.ObjectType.upce
About
Bar code and QR code generator and scanner built in Swift
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published