문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top