CustomView *customView = [[CustomView alloc] init];
[self.window.contentView addSubview:customView];
我怎样才能使窗口调整大小时customView.frame.size.height
总是等于contentView.frame.size.height
,同时customView.frame.size.width = 20;
?
Swift 版本,应用 autoresizingMask:
let customView = CustomView()
customView.autoresizingMask = [.width, .height]
self.window.contentView.addSubview(customView)
设置自定义视图的autoresizingMask:
CustomView *customView = [[CustomView alloc] init];
customView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self.window.contentView addSubview:customView];