更新时间:2023-02-12 17:17:53
您需要创建约束的IBOutlet。
You need to create an IBOutlet of your constraint.
然后在代码中设置约束的常量值:
Then you set the constant value of your constraint in code:
labelWidthConstraint.constant = newValue
如果你想要它的动画,你可以这样做:
If you want it animated you can do something like this:
labelWidthConstraint.constant = newValue
UIView.animate(withDuration: 0.3, animations: {
view.layoutIfNeeded()
}
self.labelWidthConstraint.constant = newValue;
[UIView animateWithDuration:0.3 animations:^{
[self.view layoutIfNeeded];
}];