Search code examples
iosavfoundationbarcode-scanner

iOS: AVFoundation Barcode Scanning - change scanning area


I'm using AVFoundation in order to implement barcode scanning. It works well, but I want to decide in which area the barcode has to be centered (for example on the top of the screen). How can I do this?


Solution

  • Set the rectOfInterest on your AVCaptureMetaDataOutput instance:

    self.metadataOutput.rectOfInterest = [self.previewLayer metadataOutputRectOfInterestForRect:myRectOfInterest];