QuuR-swift makes it easy to deal with QR Code data in Swift.
- iOS 8.0+
- Xcode 8
You can use Carthage to install QuuR-swift
by adding it to your Cartfile
:
github "cam-inc/QuuR-swift"
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:
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)
StaticReader.read
will return an optional array of strings [String]?
let texts = QuuR.StaticReader.read(image: SomeQRCodeImage)
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()
}
}
- Drag and drop a UIView into the desired place.
- Show Identity Inspector.
- Set Class to
Reader
and Module toQuuR
- isZoomable Enable to zoom a video input by pinching a screen.
- maxZoomScale Set it to a positive CGFloat value.
Delegate property also settable from Storyboard by right-clicking a Reader view.