Cocoa Swift:如何将AVPlayerLayer添加到NSView的后端层
我在interface builder中有一个Cocoa Swift:如何将AVPlayerLayer添加到NSView的后端层,cocoa,swift,nsview,layer,avplayerlayer,Cocoa,Swift,Nsview,Layer,Avplayerlayer,我在interface builder中有一个NSView,如下所示: 我在视图(videoView)中有按钮和标签,用于视频的播放控制。当我向视图添加AVPlayerLayer(myPlayerLayer)时,如下所示: self.videoView.layer?.addSublayer(myPlayerLayer) 它添加了AVPlayerLayer作为顶层,从而覆盖了按钮。如何将playerlayer添加到后面,使其不覆盖任何其他内容 非常感谢。通过这样做: myPlayerLayer.z
NSView
,如下所示:我在视图(videoView)中有按钮和标签,用于视频的播放控制。当我向视图添加
AVPlayerLayer
(myPlayerLayer)时,如下所示:self.videoView.layer?.addSublayer(myPlayerLayer)
它添加了
AVPlayerLayer
作为顶层,从而覆盖了按钮。如何将playerlayer添加到后面,使其不覆盖任何其他内容
非常感谢。通过这样做:myPlayerLayer.zPosition=-1
我强制
AVPlayerLayer
位于NSView
中已有的任何其他层之后。请注意,将zPosition
设置为0
不起作用;我相信按钮和标签位于0
,因此我需要进一步返回。您是否尝试使用myPlayerLayer
的'zPosition'属性?@Astoria成功了!我必须设置zPosition=-1
,尽管这样它会在zPosition=0
的按钮后面。