setAutoresizingMask from code in osx

user731990 picture user731990 · Apr 29, 2012 · Viewed 7.4k times · Source

There is a section in size inspector with name Atosizing that can set left,right,up,down layout of a control,i find that i do that with setAutoresizingMask but don't know how set it that my control layout to right and up (means when user resize window my control steak to right and up)

Answer

Justin Boo picture Justin Boo · Apr 29, 2012

Look at these -setAutoresizingMask parameters:

NSViewNotSizable

The receiver cannot be resized.

NSViewMinXMargin

The left margin between the receiver and its superview is flexible.

NSViewWidthSizable

The receiver’s width is flexible.

NSViewMaxXMargin

The right margin between the receiver and its superview is flexible.

NSViewMinYMargin

The bottom margin between the receiver and its superview is flexible.

NSViewHeightSizable

The receiver’s height is flexible.

NSViewMaxYMargin

The top margin between the receiver and its superview is flexible.


So You can do it like this:

[YourOutlet setAutoresizingMask: NSViewMinXMargin | NSViewMinYMargin];