Specially registered an account to answer this question. You should read the document carefully for the title. I didn’t read the document just because I believed you and couldn’t find it after searching for a long time. (I also blame me for not reading the post carefully, so I wasted a lot. Time, I actually saw the article "IOS QR code scanning, two things you need to pay attention to" a long time ago), and I suddenly found the rectOfInterest attribute after reading the document this morning.
Solution:
_output = [[AVCaptureMetadataOutput alloc]init];
CGSize size = self.view.bounds.size;
CGRect cropRect = CGRectMake(50, 160, 220, 220);
CGFloat p1 = size.height/size.width;
CGFloat p2 = 1920./1080.; //Using 1080p image output
if (p1 < p2) {
CGFloat fixHeight = self.view.bounds.size.width * 1920. / 1080.;
CGFloat fixPadding = (fixHeight - size.height)/2;
_output.rectOfInterest = CGRectMake((cropRect.origin.y + fixPadding)/fixHeight,
cropRect.origin.x/size.width,
cropRect.size.height/fixHeight,
cropRect.size.width/size.width);
} else {
CGFloat fixWidth = self.view.bounds.size.height * 1080. / 1920.;
CGFloat fixPadding = (fixWidth - size.width)/2;
_output.rectOfInterest = CGRectMake(cropRect.origin.y/size.height,
(cropRect.origin.x + fixPadding)/fixWidth,
cropRect.size.height/size.height,
cropRect.size.width/fixWidth);
}
01. It’s very simple. There is a function that draws the interface on this ViewController. Just add a border on the interface and leave only a small area. The disadvantage is that sometimes the QR code can be recognized even if it is displayed in the frame. , weird, but it’s okay;
02. The troublesome thing is to put this ViewController into another ViewController;
After reading this article you will know, it is very simple, you can get the full screen scanning effect you want
http://www.appcoda.com/qr-code-ios-programming-tutorial/
Specially registered an account to answer this question. You should read the document carefully for the title. I didn’t read the document just because I believed you and couldn’t find it after searching for a long time. (I also blame me for not reading the post carefully, so I wasted a lot. Time, I actually saw the article "IOS QR code scanning, two things you need to pay attention to" a long time ago), and I suddenly found the rectOfInterest attribute after reading the document this morning.
Solution:
_output = [[AVCaptureMetadataOutput alloc]init];
CGSize size = self.view.bounds.size;
CGRect cropRect = CGRectMake(50, 160, 220, 220);
CGFloat p1 = size.height/size.width;
CGFloat p2 = 1920./1080.; //Using 1080p image output
if (p1 < p2) {
CGFloat fixHeight = self.view.bounds.size.width * 1920. / 1080.;
CGFloat fixPadding = (fixHeight - size.height)/2;
_output.rectOfInterest = CGRectMake((cropRect.origin.y + fixPadding)/fixHeight,
cropRect.origin.x/size.width,
cropRect.size.height/fixHeight,
cropRect.size.width/size.width);
} else {
CGFloat fixWidth = self.view.bounds.size.height * 1080. / 1920.;
CGFloat fixPadding = (fixWidth - size.width)/2;
_output.rectOfInterest = CGRectMake(cropRect.origin.y/size.height,
(cropRect.origin.x + fixPadding)/fixWidth,
cropRect.size.height/size.height,
cropRect.size.width/fixWidth);
}
01. It’s very simple. There is a function that draws the interface on this ViewController. Just add a border on the interface and leave only a small area. The disadvantage is that sometimes the QR code can be recognized even if it is displayed in the frame. , weird, but it’s okay;
02. The troublesome thing is to put this ViewController into another ViewController;