I have created an NSView
on an NSWindow
. I'm t开发者_StackOverflow中文版rying 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?
Add an observer for the NSWindowDidResizeNotification
notification of your parent window and adjust your child window's frame accordingly.
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
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.
精彩评论