ShapeQRCode
安装
首选的安装方式为使用 CocoaPods。
要使用 CocoaPods 将 ShapeQRCode
集成到您的项目中,请在您的 Podfile
中指定它
pod 'ShapeQRCode'
之后,继续使用以下命令
$ pod install
使用方法
基本上,ShapeQRCode 支持大量不同的自定义。我将很快在更详细的文档中解释不同的可能性。但到目前为止,查看示例项目和它的代码可能非常有意思。该 示例项目 展示了 ShapeQRCode 的大部分功能。
但为了完整性,这里简要说明如何在 Swift 中生成 QR 码。
import ShapeQRCode
//use an emoji as the image in the middle
let 🦒 = "🦒".image()!
//create the image that should be contained in the qr code
let img = try? ShapeQRCode.Image(withUIImage: 🦒,
width: 0.7,
height: 0.7,
transparencyDetectionEnabled: true)
//the actual struct that encapsulates the QR code data
let qr = ShapeQRCode(withText: "https://en.wikipedia.org/wiki/Giraffe",
andImage: img,
shape: .circle,
moduleSpacingPercent: 0.002,
color: .black,
errorCorrectionLevel: .high)
//Render the qr code represented by the qr as an UIImage with 500px width/height
let renderedQRImage = qr.image(withLength: 500)
您可以在本存储库的 playground 中找到此代码。克隆/下载存储库并打开 工作区。然后使用 "ShapeQRCode" 计划(重要!)进行构建并运行 playground。
示例
例如,您可以在此处尝试使用QR码,有关样例项目,请参阅本仓库中的示例项目。那里的代码也可能帮助您将适当的ShapeQRCode解决方案集成到您的项目中。
贡献
您喜欢这个仓库吗?是否有任何问题?(显然有很多...)提交一个pull请求,打开一个issue...还有:我总是很乐意听到您的反馈!如果您有任何问题或建议,我很乐意帮助您!
许可协议
本项目遵循MIT许可协议 - 详细信息请参阅LICENSE文件
致谢
本库使用了来自Nayuki的优秀的