开发者

fixing NSWindow size?

开发者 https://www.devze.com 2023-01-28 12:50 出处:网络
How can we fix the size of NSWindow so that user should not be a开发者_如何学编程ble to resize it jus by dragging it with mouse or is there a way so that all the subviews window resizes when users cha

How can we fix the size of NSWindow so that user should not be a开发者_如何学编程ble to resize it jus by dragging it with mouse or is there a way so that all the subviews window resizes when users changes the size of window , actually the problem is that when user changes size ofwindow , subviews do not resizses thats i wanted to lock window resizing?


I may be missing the point here (and a bit late), but can you not set the 'constraints' options on the window itself?

If the min and max sizes are the same, it prevents resizing.

fixing NSWindow size?


Perhaps not the answer you're after, but you could prevent the re-size by disabling the resize indicator (via setShowsResizeIndicator) and then implementing the...

- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize

...NSWindowDelegate delegate method so that it simply returns the existing window size.

Odd that there's no "setCanResize:" method, but there you go.


The following assumes you're using Interface Builder for your window layout:

To get the subviews to resize, go to the Size Inspector (command-3) and, for each subview, set its Autoresizing struts and stretchies (click red lines in rectangle) until the preview anim does what you want. Remember: (1) If a parent view has no stretch, neither will its children; (2) If you're using scrollbars, they will never appear if the content is stretchable in the same direction as the scrollbar.

If you really need a locked window, with no controls for resizing, you can uncheck those options in the Attributes Inspector (command-1). Or, more simply, make an IBOutlet for the window and put this in your code:

[self.theWindow setStyleMask:NSBorderlessWindowMask];
0

精彩评论

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

关注公众号