固定对象位于 NSWindow 右侧
我在 NSWindow
上创建了一个 NSView
。我试图将视图“停靠”到窗口的右侧,这样当我缩放窗口时,视图将始终保持在右侧。
有什么建议吗?
I have created an NSView
on an NSWindow
. I'm trying to "dock" the view to the right side of the window, so that when I scale the window the view will always stay on the right side.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
绝不放开2024-12-04 00:57:34
使用
[myView setAutoResizingMask: NSViewMaxXMargin | NSViewMaxYMargin];
这应该使视图保持在其超级视图的右上角。如果您想要整个右侧,请使用 NSViewMaxXMargin | NSViewHeightSizeable | NSViewHeightSizeable | NSViewHeightSizeable NSViewMinYMargin | NSViewMinYMargin | NSViewMinYMargin NSViewMaxYMargin 代替。它将固定在右侧,顶部和底部将随超级视图调整大小。现在只需将其放在正确的位置,它就会留在那里。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
为父窗口的 NSWindowDidResizeNotification 通知添加观察者,并相应地调整子窗口的框架。
Add an observer for the
NSWindowDidResizeNotification
notification of your parent window and adjust your child window's frame accordingly.