简体   繁体   English

如何以编程方式仅调整 NSWIndow 的一侧?

[英]How to resize only one side of NSWIndow programmatically?

From the Apple documentation, we can modify the resizing value(multipliers) by assigning new values to ResizeIncrements.从 Apple 文档中,我们可以通过为 ResizeIncrements 分配新值来修改调整大小值(乘数)。

But The minimum value is 1 so, I was wondering if resizing only one side (only Width or only Height at a time) is possible.但是最小值是 1 所以,我想知道是否可以仅调整一侧的大小(一次仅调整宽度或仅高度)。

I've tried to use callback, resetting the size of the NSWindow each time the user drag to resize it, but it's not working.我尝试使用回调,每次用户拖动以调整其大小时重置 NSWindow 的大小,但它不起作用。

Edit:编辑:

To be more specific, I'd like to know if restricting the resizing option to only one side is possible.更具体地说,我想知道是否可以将调整大小选项限制在一侧。

Yes simply override windowWillResize:size: and return whatever value you want to allow.是的,只需覆盖windowWillResize:size:并返回您想要允许的任何值。

I don't believe resizeIncrements will affect this;我不相信resizeIncrements会影响这一点; that just sets the increments to allow but the window delegate will have the final say.这只是设置允许的增量,但 window 代表将拥有最终决定权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM