简体   繁体   中英

Fixed object to the right of an NSWindow

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?

为您的父窗口的NSWindowDidResizeNotification通知添加观察者,并相应地调整子窗口的框架。

Use

[myView setAutoResizingMask: NSViewMaxXMargin | NSViewMaxYMargin];

That should keep the view in the upper right corner of its superview. If you want the entire right side, use NSViewMaxXMargin | NSViewHeightSizeable | NSViewMinYMargin | NSViewMaxYMargin NSViewMaxXMargin | NSViewHeightSizeable | NSViewMinYMargin | NSViewMaxYMargin NSViewMaxXMargin | NSViewHeightSizeable | NSViewMinYMargin | NSViewMaxYMargin instead. It will be anchored to the right side and the top and bottom will resize with the superview. Now just place it on the right spot and it should stay there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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