I'm trying to add a play button on top of my AVPlayerLayer
but it's not showing up.
I have a UIView
called playerView
as an IBOutlet.
Here's how I create the player
and a corresponding playerLayer
, and put it in the playerView
:
player = AVPlayer()
superLayer = self.playerView.layer
playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.playerView.bounds
playerLayer.cornerRadius = 5.0
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
superLayer.addSublayer(playerLayer)
self.view.bringSubview(toFront: playVideoButton)
The problem is that the playVideoButton
doesn't show up on top of the the playerLayer
(the button is added in the storyboard). I tried hiding the playerLayer
and the button still doesn't show up underneath, so it seems the button's not even in the view hierarchy.