如何在iOS的文本字段中设置自动调整大小?
helloWorld.mself.TextFieldExample.text = @"HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD";
现在:
正确的:
在这种情况下,最佳做法是什么?
最佳答案
使用UITextField,文本必须在一行上,并且不能换行。
您有两种选择:
self.TextFieldExample.adjustsFontSizeToFitWidth = YES;
self.TextFieldExample.minimumFontSize = 10.0; //Optionally specify min size
看到这个答案:How to create a multiline UITextfield?
p.s. Per the style guide,“属性应为驼峰大小写,首字母应为小写。”因此您应该将var重命名为
self.textFieldExample