To run the example project, clone the repo, and run pod install
from the Example directory first.
サンプル プロジェクトを実行するには、リポジトリのクローンを作成し、最初にサンプル ディレクトリから「pod install」を実行します。
・iOS 13.0
・Swift 5.0
QRReader is available through CocoaPods. To install
it, simply add the following line to your Podfile:
QRReader は CocoaPods から入手できます。インストールするには
Podfile に次の行を追加するだけです。
pod 'QRReader'
create an instance
インスタンスを作成する。
let myQRCodeReader = QRReader()
Show camera screen.Delegate is tied.(You can also set the reading range with frame)
カメラの画面を表示する。delegateの紐付けがされる。(frameで読み込み範囲の設定もできる)
self.myQRCodeReader.setupCamera(vc:self)
Processing when the QR code is read
QRコードを読み込んだ時の処理。
func metadataOutput(_ output: AVCaptureMetadataOutput,
didOutput metadataObjects: [AVMetadataObject],
from connection: AVCaptureConnection) {
if let metadata = metadataObjects.first as? AVMetadataMachineReadableCodeObject {
guard let barCode = self.myQRCodeReader.previewLayer.transformedMetadataObject(for: metadata),
let barCode = barCode as? AVMetadataMachineReadableCodeObject else {
return
}
// frame following mode(枠追従モード)
self.myQRCodeReader.followingBorder(barCode.bounds)
// stopCamera
self.myQRCodeReader.stopCamera()
if let str = metadata.stringValue {
print(str)
}
}
}
KiraSoga, [email protected]
曽我 滉
QRReader is available under the MIT license. See the LICENSE file for more info.
QRReader は MIT ライセンスの下で利用できます。詳細については、LICENSE ファイルを参照してください。