gpt4 book ai didi

ios - 如何动态更改 UILabel 的宽度?

转载 作者:行者123 更新时间:2023-11-28 23:25:52 27 4
gpt4 key购买 nike

所以我想在每次按下按钮时更改 UILabel(进度条)的长度

下面是我在 View Controller 中设置标签的方法

@IBOutlet weak var progressLabel: UILabel!

@IBAction func answerPressed(_ sender: AnyObject) {
progressBar.frame.size.width = progressBar.frame.size.width + 100
}

但是我不断获得相同的progressBar.frame.size.width值,是否有一个独特的函数来设置宽度?

The yellow bar Does not increase in width after clicking the answerPressed

最佳答案

为标签设置约束,如果文本数量增加,它会自动适应文本。

关于ios - 如何动态更改 UILabel 的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58745860/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com