Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa Swift:如何将AVPlayerLayer添加到NSView的后端层_Cocoa_Swift_Nsview_Layer_Avplayerlayer - Fatal编程技术网

Cocoa Swift:如何将AVPlayerLayer添加到NSView的后端层

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

我在interface builder中有一个
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
的按钮后面。