I have one main NSWindow which is empty, and 5 NSViews. The NSViews have different buttons and labels etc, and the window is empty. The first view displayed is a menu, linking to the other views and back. This works fine and the views switch well.
However if the NSWindow is a certain size, and the NSView is bigger, then it spills out of the NSWindow and gets cut off.
Is there any way such that when I do:
[_window setContentView: theNewView];
to also have _window
resize to fit the new view? If this is possible, can this be done with an animation?
Best Answer
-[NSWindow setContentSize:]
does this (without animation). Give it the desired size of the content view and it will resize both content view and the window appropriately, e.g.For animation, you need to compute window size manually using
frameRectForContentRect:
and then change window's frame withanimate:YES
: