title: IOS Swift - Camera view overlay shouldn't cover status bar
body: <p><a href="https://i.stack.imgur.com/OYOcp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OYOcp.png" alt="enter image description here"></a>I am learning Swift - making progress. My application should scan a barcode. I am trying to show the camera in the middle of the screen between two strips of spaces above and below the UIview. There is a button at bottom strip of space to save the barcode number. My issue is, I need to show the status bar at the top of the screen with signal strength, time, battery etc., when user is scanning, but it is covered by the UI view when it open camera. I have reviewed other posts and incorporated the suggestions, but the issue persists. Any help is appreciated. </p>
  
  <p>I have uploaded image showing the covered status bar. </p>
  
  <p>Here is my code:</p>
  
  <hr>
  
  <pre><code>class ScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
  
  @IBOutlet weak var cameraView: UIView!
  
  @IBOutlet weak var selectScan1: UIButton!
  
  var captureSession: AVCaptureSession!
  var previewLayer: AVCaptureVideoPreviewLayer!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
     // view.backgroundColor = UIColor.black
      captureSession = AVCaptureSession()
  
      guard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else { return }
      let videoInput: AVCaptureDeviceInput
  
      do {
          videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice)
      } catch {
          return
      }
  
      if (captureSession.canAddInput(videoInput)) {
          captureSession.addInput(videoInput)
      } else {
          failed()
          return
      }
  
      let metadataOutput = AVCaptureMetadataOutput()
  
      if (captureSession.canAddOutput(metadataOutput)) {
          captureSession.addOutput(metadataOutput)
  
          metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
          metadataOutput.metadataObjectTypes = [.ean8, .ean13, .pdf417]
      } else {
          failed()
          return
      }
  
      previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
  
      previewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
  
      previewLayer?.frame = self.cameraView.layer.frame
      cameraView.layer.addSublayer(previewLayer!)
      // **** note: select click to bounds check box in storyboard
  
      captureSession.startRunning()
  }
  </code></pre>
  
  <hr>
  
  <p><a href="https://i.stack.imgur.com/xppN4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xppN4.jpg" alt="I"></a> </p>
  
  <p><a href="https://i.stack.imgur.com/M4mzF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M4mzF.jpg" alt="enter image description here"></a></p>