问题
I have given an aspect ratio constraint of 1:2 for an imageView in my xib. I have created an IBOutlet for the constraint. Now I need to change the aspect ratio to 1:1 for certain criteria. I want to know whether there is any way to change the constraint's multiplier value other than removing the old constraint and putting in a new one??
回答1:
I think its not possible other than the 'remove and replace constraint' method.
回答2:
The multiplier is a get only property. So you can change only constant and isActive.
The constant for this constraint changes the height. If constant == width, then the height would be zero.
It's better to add height and width constraints and change them in code.
来源:https://stackoverflow.com/questions/30773182/how-can-i-change-the-aspect-ratio-constraint-value-from-code