title: How to add overlay on AVCaptureVideoPreviewLayer?
body: <p>I am building an iOS app using Swift which requires QR code scanner functionality.</p>
  
  <p>I have implemented a QR code scanner using AVFoundation, right now my capture screen looks same as a video recording screen i.e. <code>AVCaptureVideoPreviewLayer</code> shows what is being captured by the camera. </p>
  
  <p>But since it is a QR code scanner and not a regular image or video capture, I would like my <code>VideoPreviewLayer</code> to look like this: 
  <a href="https://i.stack.imgur.com/qnUsH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qnUsH.jpg" alt="camera overlay screenshot"></a></p>
  
  <p>I understand this can be achieved by adding another <code>VideoPreviewLayer</code> on top of one <code>VideoPreviewLayer</code>.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>How do I add the borders only to the edges in the upper (or smaller) preview layer?</p></li>
  <li><p>How do I change the brightness level for the <code>VideoPreviewLayer</code> in the background?</p></li>
  <li><p>How to ignore media captured by the the background layer?</p></li>
  </ol>