You can create an IBOutlet for any constraint that you want to change programmatically. Then change the constraint using the NSLayoutConstraint constant property in the code through its output link. It works very well. You can distinguish between width, height and position in this way. You cannot change the NSLayoutConstraint multiplier property, though (it is read-only). But that doesnβt matter, because what you could accomplish by defining the constraint multiplier property in Interface Builder (to get a proportional value), you can also accomplish by doing the math in your code and changing the constant property.
Alternative approach: you can disable the translation of the resize mask (for example, the UIView translatesAutoresizingMaskIntoConstraints property set to nil) and create software restrictions from scratch for which the recommended approach (easier to use) is called the visual format. But creating constraints entirely in software is more work than using the Autolayout Interface Builder to create an rough draft of your views, and then by selectively selecting software constraints after the fact, at least in typical simple cases.
source share