title: AVCaptureSession and Preview Layer does not fill entire screen
body: <p>So, I'm trying to use the camera on my phone in my app, and I was successful, but unfortunately, when using the preview, the layer does not fill the entire screen <a href="https://i.stack.imgur.com/rkx2W.jpg" rel="nofollow noreferrer">Here is an image to show you what it looks like</a></p>
  
  <p>Here's my code:</p>
  
  <pre><code>if let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) {
          self.previewLayer = previewLayer
          self.view.layer.addSublayer(self.previewLayer)
          self.previewLayer.frame = self.view.layer.frame
          captureSession.startRunning()
  
          let dataOutput = AVCaptureVideoDataOutput()
          dataOutput.videoSettings = [(kCVPixelBufferPixelFormatTypeKey as NSString):NSNumber(value:kCVPixelFormatType_32BGRA)]
  
          dataOutput.alwaysDiscardsLateVideoFrames = true
  
          if captureSession.canAddOutput(dataOutput) {
              captureSession.addOutput(dataOutput)
          }
  
          captureSession.commitConfiguration()
  
  
          let queue = DispatchQueue(label: "com.Osmo.captureQueue")
          dataOutput.setSampleBufferDelegate(self, queue: queue)
      }
  </code></pre>