Macos NSView自动调整大小以适应contentview

Macos NSView自动调整大小以适应contentview,macos,cocoa,nsview,Macos,Cocoa,Nsview,当窗口调整大小时,如何使customView.frame.size.height始终等于contentView.frame.size.height,同时customView.frame.size.width=20?设置自定义视图的自动重新设置任务: CustomView *customView = [[CustomView alloc] init]; customView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; [

当窗口调整大小时,如何使
customView.frame.size.height
始终等于
contentView.frame.size.height
,同时
customView.frame.size.width=20

设置自定义视图的自动重新设置任务:

CustomView *customView = [[CustomView alloc] init];
customView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self.window.contentView addSubview:customView];

Swift版本,用于应用自动重新定位任务:

CustomView *customView = [[CustomView alloc] init];
customView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self.window.contentView addSubview:customView];

let customView = CustomView()
customView.autoresizingMask = [.width, .height]
self.window.contentView.addSubview(customView)