从顶部调整 NSWindow 的大小
我想通过改变框架的高度并使其脱离窗口顶部来缩小 NSWindow。 我尝试过:
NSRect frame = [mainWindow frame];
frame.origin.y += 71;
frame.size.height -= 71;
[mainWindow setFrame:frame display:YES animate:YES];
但它使窗口从底部变小,而不是从顶部变小。
I want to shrink a NSWindow, by changing the height of the frame and having that come off of the top of the window.
I tried:
NSRect frame = [mainWindow frame];
frame.origin.y += 71;
frame.size.height -= 71;
[mainWindow setFrame:frame display:YES animate:YES];
But it made the window smaller from the bottom, not the top.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 OS X 上的 cocoa 中,原点位于屏幕的左下角。这意味着增加窗口的 y 位置会将其在屏幕上向上移动。由于您想要更改窗口的顶部,因此您希望底角保持在原位,这意味着您不应该更改原点。简单地改变高度就会导致窗口从顶部缩小。
In cocoa on OS X, the origin is in the bottom left corner of the screen. This means that increasing the y position of a window will move it up the screen. Since you want to change the top of your window, you want the bottom corner to stay in place, which means you should not change your origin. Simply changing the height will cause your window to shrink from the top.