Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.
/ quur-swift Public archive

Minimal QR code Read/Write framework for Swift

Notifications You must be signed in to change notification settings

cam-inc/quur-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuuR-swift

Platform Carthage compatible

QuuR-swift makes it easy to deal with QR Code data in Swift.

Requirements

  • iOS 8.0+
  • Xcode 8

Carthage

You can use Carthage to install QuuR-swift by adding it to your Cartfile:

github "cam-inc/QuuR-swift"

Usage

In iOS10+, you will need first to reasoning about the camera use. For that you'll need to add the Privacy - Camera Usage Description (NSCameraUsageDescription) field in your Info.plist:

capture of Info.plist

Generate a QR Code from a given string.

Standard QRCode

let code = QuuR.Code(from: "https://github.com/", quality: .high)
let imageView = UIImageView(image: code.image)

Colored QRCode

var code = QuuR.Code(from: "https://github.com/", quality: .high)
code.backgroundColor = CIColor(red: 0.0, green: 1.0, blue: 0.5)
code.color = CIColor(red: 0, green: 0, blue: 0)
let imageView = UIImageView(image: code.image)

Design QRCode

When you set true to isAutoAdjustingColor, QuuR.Code will detect the primary color of the centerImage and use it to the foreground color of the QRCode.

var code = QuuR.Code(from: "https://github.com/", quality: .high)
code.errorCorrectionLevel = .high
code.centerImage = UIImage(named: "SomeImage")
code.isAutoAdjustingColor = true
let imageView = UIImageView(image: code.image)

Read from UIImage

StaticReader.read will return an optional array of strings [String]?

let texts = QuuR.StaticReader.read(image: SomeQRCodeImage)

Read QRCode from Camera input

class ViewController: UIViewController {
    @IBOutlet weak var reader: Reader!

    override func viewDidLoad() {
        super.viewDidLoad()
        reader.startDetection()
    }
}

extension ViewController: ReaderDidDetectQRCode {

    public func reader(_ reader: Reader, didDetect text: String) {
        print(text)
        reader.stopDetection()
    }
}

Use QuuR.Reader with Storyboard

  1. Drag and drop a UIView into the desired place.
  2. Show Identity Inspector.
  3. Set Class to Reader and Module to QuuR

IBInspectable properties

  1. isZoomable Enable to zoom a video input by pinching a screen.
  2. maxZoomScale Set it to a positive CGFloat value.

Delegate

Delegate property also settable from Storyboard by right-clicking a Reader view.