However, while that approach is easy to read – and perfectly fine while you’re learning or if you don’t have complex layouts – there is a more efficient way. NSLayoutConstraint has a class method called activate() that activates multiple constraints at once, which should allow Auto Layout to update its entire layout as a single batch.

The code for this is straightforward: just pass in an array of constraints to the activate() method, like this:

If you need to deactivate constraints, there’s an equivalent deactivate() method that is used the same way.

Note: Auto Layout is smart enough to bulk actual layout changes even with the isActive approach – i.e., it will only call layoutSubviews() once per view even if you change four constraints – but Apple says that using activate() is definitely more efficient.