Question

How can I get a NSTextField (or any object) to respect the autoresizing options below via code? I want to add new objects to the view dynamically, but when I increase the height of the view, they are anchored to the bottom left, as opposed to the top left as shown, and so new textfields are dropped on top of the old ones.

Is this even possible via code?

Autoresize

Was it helpful?

Solution

Anything you can do in Interface Builder you can do through code.

[myTextField setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];

This means that the margin between the right edge of the textView and its superview will be flexible, as will the margin between the bottom edge and its superview. Everything else is static.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top