主要功能
* 二維碼掃描
* 二維碼生成
* 二維碼圖片識別
使用CocoaPods. 安裝
pod "YLSwiftScan"
相關(guān)參數(shù)設(shè)置
注意要在.plist設(shè)置相機(jī)相關(guān)的權(quán)限
//初始化
let manager = YLScanViewManager.shareManager()
//視圖UI相關(guān)的設(shè)置更改,可以不做設(shè)置,使用默認(rèn)配置
// 是否需要邊框
//manager.isNeedShowRetangle = true
//掃描框的寬高比
// manager.whRatio = 1
//相對中心點Y的偏移
//manager.centerUpOffset = -20
//掃描框的寬度
// manager.scanViewWidth = 160
//掃描框的顏色
//manager.colorRetangleLine = UIColor.red
//4角與掃描框的位置關(guān)系
//manager.photoframeAngleStyle = YLScanViewPhotoframeAngleStyle.Outer
//掃描框4角的顏色
//manager.colorAngle = UIColor.red
//掃碼區(qū)域4個角的線條寬度
//manager.photoframeLineW = 4
//掃描動畫的樣式,自帶4種樣式
// manager.imageStyle = YLAnimationImageStyle.secondeNetGrid
//自定義掃描動畫
manager.animationImage = image
//添加掃描成功返回代理
manager.delegate = self
調(diào)用方法
let manager = YLScanViewManager.shareManager()
manager.isNeedShowRetangle = true
manager.imageStyle = YLAnimationImageStyle.secondeNetGrid
manager.delegate = self
manager.showScanView(viewController: self)
在YLScanViewManagerDelegate的代理中處理成功后返回的數(shù)據(jù)
func scanSuccessWith(result: YLScanResult) {
print("wlg====%@",result.strScanned!)
}
二維碼的生成
// frame: 生成視圖的frame
// logoIconName:是否需要logo??蛇x
// codeMessage: 二維碼包含信息
//例如
let codeView = manager.produceQRcodeView(frame: CGRect(x: (self.view.bounds.size.width - 200)/2, y: self.view.bounds.size.height/2, width: 200, height: 200), logoIconName: nil,codeMessage: "wlg's test Message")