> To get the constraints, we can use the get only property “constraints”, which gives an array of constraints. To get each constraint, we can iterate through the resulted array.

If your constraints are defined in a storyboard or xib, you can just create an IBOutlet for the constraint. Then it’s trivial to change the constant for that constraint.

If you don’t need to support iOS 8 and earlier, layout anchors are a much simpler way to create constraints in code than the old NSLayoutConstraint initialiser. See https://developer.apple.com/documentation/uikit/nslayoutanchor

Written by

Independent and freelance software developer for iPhone, iPad and Mac

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store