虽然我在我的 ViewController 类中输入了这段代码,但我的应用程序看起来是这样的:
@IBOutlet var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label.text = "Hello World"
label.adjustsFontSizeToFitWidth = true
label.numberOfLines = 1
label.minimumScaleFactor = 0.1
}
最佳答案
您的文本数据不超过 label
宽度,这就是为什么标签 text
font
与已设置的相同。
如果您的文本数据大于标签宽度
,那么它将根据宽度
调整字体
。
Please check with label text: "This is the demo to test label text is adjustable or not. You need to test it with this demo data"
您的标签字体
将根据宽度进行调整。
关于swift - 标签不调整字体大小以适应宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50193860/