Cocoa auto-resize window

How can I make NSWindow with NSTabView smooth resize when the user clicks on the tab? I want him to like the System Privileges application: the window resizes to fit the content.

+3
source share
1 answer

Use NSWindow setFrame: animated: method. If you want to resize the window down, make sure that you reduce the y coordinate of the beginning by the same amount as the window size. To also resize views in the window, make sure that you have correctly configured your autoresist properties.

NSWindow *window;
CGFloat widthChange, heightChange;

NSRect frame = [window frame];
frame.size.width += widthChange;
frame.size.height += heightChange;
frame.origin.y -= heightChange;
[window setFrame:frame animated:YES];
+7
source

Source: https://habr.com/ru/post/1788541/


All Articles