版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yaojinhai06/article/details/73571986
iOS读取相册二维码请使用官方的方法.现在开始练习起来.
func beginQRImage(image:UIImage) -> Void {
let detector = CIDetector(ofType: CIDetectorTypeQRCode, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh]);
let url = URL(fileURLWithPath: Bundle.main.path(forResource: "timg", ofType: "jpeg")!);
let ciImage = CIImage(contentsOf: url);
let feature = detector?.features(in: ciImage!);
for item in feature! {
print("type = \(item.type)");
if let qrFeature = item as? CIQRCodeFeature {
print(qrFeature.messageString);
}
}
}
就这个以方法就可了.
哦哦,忘了说一下,需要导入CoreImage这个库才行哦.