How to update the constant height constraint of a UIView programmatically?

后端 未结 9 2296
执笔经年
执笔经年 2020-11-27 11:16

I have a UIView and I set the constraints using Xcode Interface Builder.

Now I need to update that UIView instance\'s height constant progra

9条回答
  •  感情败类
    2020-11-27 12:09

    Select the height constraint from the Interface builder and take an outlet of it. So, when you want to change the height of the view you can use the below code.

    yourHeightConstraintOutlet.constant = someValue
    yourView.layoutIfNeeded()
    

    Method updateConstraints() is an instance method of UIView. It is helpful when you are setting the constraints programmatically. It updates constraints for the view. For more detail click here.

提交回复
热议问题