Closed mnbh96 closed 1 year ago
Have you got the latest version? LogoTemplate was added in 11.0.0 so please check that you have (at least) this version in your project.
Can you open the demo project in QRCode/Demo/QRCodeView Demo/
and see if you can compile the macOS Logo Image Demo
target?
I created a new SwiftUI project, imported QRCode
and was able to use the LogoTemplate functionality as expected. Can you give me any more information as to how you're trying to use the library? macOS/iOS/tvOS/watchOS?
import SwiftUI
import QRCode
struct ContentView: View {
let doc: QRCode.Document = {
let d = QRCode.Document(utf8String: "Testing https://github.com/dagronf/QRCode/issues/10")
let path = CGPath(
rect: CGRect(x: 0.65, y: 0.75, width: 0.35, height: 0.25),
transform: nil
)
let image = NSImage(systemSymbolName: "rectangle.inset.filled.and.person.filled", accessibilityDescription: nil)
let logoTemplate = QRCode.LogoTemplate(path: path, image: image?.cgImage(forProposedRect: nil, context: nil, hints: nil))
d.logoTemplate = logoTemplate
return d
}()
var body: some View {
VStack {
QRCodeDocumentUIView(document: doc)
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The SwiftUI preview shows
Here's the project I created.
@mnbh96 any luck with this?
Yes it worked.
For some reason Xcode decided to install version 9 instead of the latest version. I have updated the package like you said and now it works. Thank you.
Brilliant!
I can't add logo to the qrcode
I'm using SwiftUI
"Value of type 'QRCode.Document' has no member 'logoTemplate'"