我正在添加一个子视图(NSView
),这是我的代码:
override func viewDidAppear() {
self.view.needsDisplay = true
let newView = NSView()
newView.autoresizesSubviews = true
newView.frame = view.bounds
newView.wantsLayer = true
newView.layer?.backgroundColor = NSColor.green.cgColor
view.addSubview(newView)
}
它工作正常
你们中的任何人都知道为什么或如何使用超级视图调整子视图的大小吗?
我会非常感谢你的帮助