-[NSTextField intrinsicContentSize] always has undefined width

后端 未结 2 1783
面向向阳花
面向向阳花 2021-01-18 06:54

I\'m pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it\'s stringValue.

If I create a textField programmatica

2条回答
  •  不思量自难忘°
    2021-01-18 07:39

    OK, finally figured it out…

    [_textfield setEditable:NO]

    That's it. I guess that with an editable textfield one must have an explicit constraint for the textfield width. Which kind of makes sense, imagine editing a textfield and it would constantly grow horizontally with every keystroke... not an ideal UI.

提交回复
热议问题