如何调整文本大小以适合UITextField

时间:2022-10-12 21:13:59

I am trying to get text to resize automatically to fit a UITextField. I have the adjust to fit value set in interface builder but what happens when I build and go is the text goes from the default size, to the minimum size and never increases in size when less text is in the box.

我试图让文本自动调整大小以适应UITextField。我有调整以适应界面构建器中设置的值,但是当我构建和运行时会发生的情况是文本从默认大小变为最小大小,并且当框中的文本较少时,大小不会增加。

I want to get text to work the way it does in apples iPhone calculator. How do I do this?

我希望文本能像苹果iPhone计算器那样工作。我该怎么做呢?

1 个解决方案

#1


Text fields will never make text bigger. They will only reduce it in size from the default to the minimum size.

文本字段永远不会使文字变大。它们只会将其大小从默认大小减小到最小大小。

So, you need to change your defalt text size to be bigger.

因此,您需要将您的defalt文本大小更改为更大。

Keep in mind that you're working with both a height and a width. Unless you have a square text field, no amount of adjustments will fill the field in both directions.

请记住,您正在使用高度和宽度。除非您有方形文本字段,否则不会在两个方向上填充该字段。

#1


Text fields will never make text bigger. They will only reduce it in size from the default to the minimum size.

文本字段永远不会使文字变大。它们只会将其大小从默认大小减小到最小大小。

So, you need to change your defalt text size to be bigger.

因此,您需要将您的defalt文本大小更改为更大。

Keep in mind that you're working with both a height and a width. Unless you have a square text field, no amount of adjustments will fill the field in both directions.

请记住,您正在使用高度和宽度。除非您有方形文本字段,否则不会在两个方向上填充该字段。