ZXingObjc encode QR code
To generate QR code in iOS device, I’m using this library.
From the their GitHub repo, already got the instruction. Here I want to point out 2 things:
1. Assign to UIImage
1 | NSString *text = @"The text to encode"; |
See the code above, it will crash when convert CGImageRef
to UIImage
.
So change to
1 | UIImage *image = [[UIImage alloc] initWithCGImage:[[ZXImage imageWithMatrix:result] cgimage]]; |
It works now. This is something to do with ARC, checkout this for more info
2. It has margin
You can see the margin took out some space. To remove the margin
1 | ... |
Run it again, now it utilise the whole image.
References: