gpt4 book ai didi

ios - 使用约束以编程方式创建 UILabel。现在我想更新 UILabel 的高度限制

转载 作者:行者123 更新时间:2023-11-28 13:32:56 25 4
gpt4 key购买 nike

我的代码如下

movieDescLbl.translatesAutoresizingMaskIntoConstraints = false
movieDescLbl.heightAnchor.constraint(equalToConstant: 87).isActive = true

我不确定如何以编程方式更新高度限制。

最佳答案

创建变量

var heightCon:NSLayoutConstraint!

赋值

heightCon = movieDescLbl.heightAnchor.constraint(equalToConstant: 87)
heightCon.isActive = true

更新

heightCon.constant = 200
view.layoutIfNeeded()

heightCon.isActive = true/false

关于ios - 使用约束以编程方式创建 UILabel。现在我想更新 UILabel 的高度限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57076848/

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