Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bar code and QR code generator and scanner built in Swift

NotificationsYou must be signed in to change notification settings

satyadevchauhan/CodeGeneratorAndScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to generate Bar code or QR code on iOS using native iOS APIs?

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:

Bar Code Example

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()}}

QR Code Example

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()}}

How to scan Bar code or QR code on iOS using native iOS APIs?

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:


[8]ページ先頭

©2009-2025 Movatter.jp