In IB this can be done easily by checking the 'Resize' checkbox on or off. My problem is I want my main NSWindow to not be resizable, until a button is clicked, and then i want it to be resizable.
I've scoured the Internet but can't find anything? Can a window not be made to be resizable or not programmatically?
Thanks in advance everyone!
Since 10.6, you can change the style mask of a window using -[NSWindow setStyleMask:]
. So, you'd do something like this:
In Objective-C
To make it resizable:
window.styleMask |= NSWindowStyleMaskResizable;
To make it non-resizable:
window.styleMask &= ~NSWindowStyleMaskResizable;
In Swift
To make it resizable:
mainWindow.styleMask = mainWindow.styleMask | NSWindowStyleMaskResizable
To make it non-resizable:
mainWindow.styleMask = mainWindow.styleMask & ~NSWindowStyleMaskResizable