我的代码如下
movieDescLbl.translatesAutoresizingMaskIntoConstraints = false
movieDescLbl.heightAnchor.constraint(equalToConstant: 87).isActive = true
我不确定如何以编程方式更新高度限制。
答案 0 :(得分:1)
创建变量
var heightCon:NSLayoutConstraint!
分配
heightCon = movieDescLbl.heightAnchor.constraint(equalToConstant: 87)
heightCon.isActive = true
更新
heightCon.constant = 200
view.layoutIfNeeded()
OR
heightCon.isActive = true/false