I am trying to resize a Window Form after it loads and have done quite a bit of searching for code to do it.
Here is one code snippet that works to size the form during the design phase.
self.view.window?.contentMinSize = CGSize(width: 1100, height: 310)
I have tried code like below to increase the window size after the Form loads
if let myWindow = self.view.window ?? NSApplication.shared.mainWindow
{
// Increase window size and position after it loads
let newRect = NSRect(x: 100, y: 100, width: 1400, height: 900)
}
It seems that this code not only changes the Form size after loading, but also changes the size of the Form in Main.swift, which is something I don't want.
I read elsewhere that I had to disable constraints to resize the Form, so I tried code below.
let tableView = NSTableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
let newRect = NSRect(x: 100, y: 0, width: 1100, height: 600)
myWindow?.setFrame(newRect, display: true)
That code did not seem to do anything as well.
Also, the Form displays in the lower left of the screen.
Note that main reason I want to resize the Form after loading is to keep it smaller during design development. The same goes for the NSTableView, which I have not gotten to yet.