Q: AVPlayerLayer is not changing size to bounds of cell I'm trying to get AVPlayerLayer to fill up cell space, but by setting the frame property it's not changing its size.
In my custom cell file:
 override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)


    let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
    let player = AVPlayer(url: videoURL! as URL)
    let playerLayer = AVPlayerLayer(player: player)
    playerLayer.frame = contentView.bounds;
    contentView.layer.addSublayer(playerLayer)
    player.play()
}

Then in my uitableviewcontroller file:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "clipHomeCells", for: indexPath) as! ClipTableViewCell
    // Configure the cell...
    return cell
}

But it looks like this:


A: CALayer objects don't automatically resize to fill the view they belong to when that expands. So, the layer still has the same frame you gave it initially. If the cell size changes later because of auto layout or the heightForRow(at:) delegate method, the CALayer frame will not be updated to match. 
The way I have handled this in the past is by creating a custom subclass of UITableViewCell which manages the CALayer and sizes it appropriately in layoutSubviews(). 

A: I had the same problem, solution was to use UICollectionView instead or in this case if videolayer have same size as cell.view you can use playerLayer.frame = cell.bounds in cellForRowAtIndexPath.
