title: How to access the leading and trailing of the AVPlayerLayer when the videoGravity is set to resizeAspect?
body: <p>I was wondering if it's possible to access the leading anchor and the trailing anchor of the <code>AVPlayerLayer</code> especially when the <code>videoGravity</code> property is set to <code>resizeAspect</code>. (I added an image and used red text to indicate where it is).</p>
  <p>Currently, I'm working on a video camera app, and the view file, <code>LiveCameraView</code>, has one <code>UIView</code>, <code>videoView</code>, and the <code>videoView</code> is pinned to the <code>LiveCameraView</code>'s safe area (only the leading and trailing).
  I want to set the <a href="https://developer.apple.com/documentation/avfoundation/avplayerlayer/1388915-videogravity" rel="nofollow noreferrer"><code>videoGravity</code></a> as <code>.resizeAspect</code>, but I also want to pin the translucent black area's trailing (on the right side of the view which covers red and white record button) to the right-side edge of where the image is captured.</p>
  <p>Sorry, it's hard to explain, but when I set the value to <code>.resizeAspectFill</code>, the whole width of the translucent black areas appeared. I want that happens when I use <code>resizeAspect</code> as well. So the right side of the <code>LiveCameraView</code> should display</p>
  <ul>
  <li>the full width of the translucent black area</li>
  <li>the black area since using resizeAspect</li>
  <li>Blue background area</li>
  </ul>
  <p>So, I want to make sure somehow get the leading and the trailing of the <code>AVPlayerLayer</code> without the complete black area.
  The <code>HKView</code> is a library I'm using and it's super class is <code>UIView</code>.</p>
  <pre><code>import AVFoundation
  
  lazy var videoView: HKView = {
      let view = HKView()
      view.videoGravity = .resizeAspect
      return view
  }()
  
  lazy var rightContainerView: UIView = {
      let view = UIView()
      view.backgroundColor = UIColor.translucentBlack()
      return view
  }()
  
  required override init(frame: CGRect) {
      super.init(frame: frame)
      setupViews()
      setupConstraints()
      self.backgroundColor = .blue // put this for testing
  }
  
  func setupViews() {
      self.addSubview(videoView)
      hkView.addSubview(rightContainerView)
      rightContainerView.addSubview(recordButton)
  }
  
  
  func setupConstraints() {
      caneraView.anchor(top: self.topAnchor, leading: self.safeAreaLayoutGuide.leadingAnchor, bottom: self.bottomAnchor, trailing: self.safeAreaLayoutGuide.trailingAnchor)
      
      rightContainerView.translatesAutoresizingMaskIntoConstraints = false
      NSLayoutConstraint.activate([
          rightContainerView.topAnchor.constraint(equalTo: cameraView.topAnchor),
          rightContainerView.bottomAnchor.constraint(equalTo: cameraView.bottomAnchor),
          rightContainerView.trailingAnchor.constraint(equalTo: cameraView.trailingAnchor),
          rightContainerView.widthAnchor.constraint(equalTo: cameraView.widthAnchor, multiplier: 0.15)
      ])
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/sTbck.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sTbck.jpg" alt="enter image description here" /></a></p>