Previously recorded scanned QR code using Apple's original Avfoundationo class library: http://www.cnblogs.com/foxting/p/4733226.html, which records how to set the scan area.
Avcapturemetadataoutput has an attribute rectofinterest, set your area.
First set the video area to the screen: Self.layer? frame = Self.view.bounds
Look at the Rectofinterest note will know its area size is first set top and then set left, valid range is (0,0,1,1)
@discussion
The value of this property was a cgrect that determines the receiver's rectangle of interest for each frame of video.
The rectangle's origin is top left and are relative to the coordinate space of the device providing the metadata. Specifying
A rectofinterest may improve detection performance for certain types of metadata. The default value of the
Value CGRectMake (0, 0, 1, 1). Metadata objects whose bounds do no intersect with the rectofinterest won't be returned.
Type the following code
Let x = (self.view.bounds.size.width-268)/2let Beginningx = X/self.view.bounds.widthlet beginningy = 106/self.view . bounds.heightlet width = 268/self.view.bounds.widthlet height = 268/self.view.bounds.heightlet InterestedRect = CGRec Tmake (beginningy, beginningx, height, width) Let output = Avcapturemetadataoutput () Output.rectofinterest = Interestedrect
The effect of the implementation is still possible, this setting is quite convenient. Pangkor
Original Apple scan QR code designated area