在扩展坞之外调整NSWindow的大小 [英] Resizing NSWindow beyond the dock

查看:170
本文介绍了在扩展坞之外调整NSWindow的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将NSWindow调整为特定大小:

I am trying to resize an NSWindow to a certain size:

NSRect frame = [_window frame];

frame.size.width = 1024;
frame.size.height = 768 + 42; // add 42 for window frame

[_window setFrame: frame display: YES];
[_window center];

调整后的高度始终固定在Mac OS X应用程序底座上,因此在我的情况下,窗口高度内的视图将不是768,而是680.是否有办法迫使它调整尺寸超出底座?

The adjusted height is always clipped at the Mac OS X application dock so in my case the view inside the window height will not be 768 but 680. Is there a way to force it to resize beyond the dock?

推荐答案

通过实现子类以覆盖在Mac开发者库的NSWindow类参考中,constrainFrameRect:toScreen:

From the Mac Developer Library, NSWindow Class Reference, constrainFrameRect:toScreen:

如果窗口可调整大小,并且窗口的高度大于屏幕高度,则矩形的高度也将调整为适合屏幕范围.矩形的宽度和水平位置不受影响.您不需要自己调用此方法;每当将标题为NSWindow的对象放置在屏幕上并更改其大小时,就会自动调用它(并使用修改后的框架来定位和设置窗口的大小). 子类可以重写此方法,以防止实例受到约束或以不同的方式约束它们.

If the window is resizable and the window’s height is greater than the screen height, the rectangle’s height is adjusted to fit within the screen as well. The rectangle’s width and horizontal location are unaffected. You shouldn’t need to invoke this method yourself; it’s invoked automatically (and the modified frame is used to locate and set the size of the window) whenever a titled NSWindow object is placed onscreen and whenever its size is changed. Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.

这篇关于在扩展坞之外调整NSWindow的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆