bigelerow
bigelerow

Reputation: 533

Swift: How to add AVPlayerLayer to back layer of NSView

I have an NSView in interface builder like so:

Set up

I have buttons and a label inside the view (videoView) for playback control of a video. When I add an AVPlayerLayer (myPlayerLayer) to the view like so:

self.videoView.layer?.addSublayer(myPlayerLayer)

It adds the AVPlayerLayer as the top layer, thereby covering the buttons. How can I add the playerlayer to the back so it doesn't cover any of the other content?

Thanks a lot.

Upvotes: 2

Views: 1499

Answers (1)

bigelerow
bigelerow

Reputation: 533

By doing:

myPlayerLayer.zPosition = -1

I forced the AVPlayerLayer to be behind any other existing layers already in the NSView. Note that setting zPosition to 0 does not work; I believe the buttons and labels were at 0 and so I needed to go further back.

Upvotes: 8

Related Questions