You didn't explain the exact relationship between cellContentCollectionView
and playerLayer
, so I'm going to assume the worst: that playerLayer
is not a subview of cellContentCollectionView
.
I also suspect that playerLayer
is not actually a view at all, but is a CALayer
. That's okay, because on iOS, a view's frame
is always its layer.frame
, so we can just deal with the layers.
The frame
of a layer is in the geometry of its superlayer. So you must ask its superlayer to convert its frame
. But, if the layer isn't transformed, you could instead ask the layer to convert its own bounds
instead.
If you intend to use the resulting rectangle as the frame of a target layer, you must convert to the target layer's superlayer. You can't just convert to the target layer's geometry and set the target layer's bounds
, because that doesn't update the position
of the target layer.
Thus I think you want to write this:
if
let playerLayer = playerLayer,
let fullScreenPlayerSuper = fullScreenPlayerView.layer.superlayer
{
let frame = playerLayer.convert(playerLayer.bounds, to: fullScreenPlayerSuper)
fullScreenPlayerView.frame = frame
}