开发者

Cocoa auto-resizable window

How can I make my NSWindow with NSTabView smoothly resize when user clicks a tab? I want it to like "System P开发者_运维百科referances" application: window changes its size according to content.


Use NSWindow's setFrame:animated: method. If you want to resize the window down, make sure you decrease the y coordinate of the origin by the same amount you increase the size of the window. To also resize the views in the window, make sure you set up their autoresizing properties correctly.

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜