Imagine there’s no translatesAutoresizingMaskIntoConstraints. It’s easy if you try. No constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant: below us, above us only sky. Imagine your app not crashing because you left a “]” out of constraintsWithVisualFormat, woohoo.
*Cough* Sorry about that, folks. Let’s move on.
I’ve written before about the superiority of programmatically doing your layout code, but there is no denying that the tools for doing so are kinda kludgy. AutoLayout is powerful and flexible but we are in need – in need! – of some syntactic sugar of some kind.
You could write a lot of helper methods for this purpose, or you could just use PureLayout.
PureLayout is an open source library that makes AutoLayout a lot less painful to deal with. Say goodbye to manually setting translatesAutoresizingMaskIntoConstraints for your views, local view defines because you can’t have self.aButton in your view dictionaries, even [view addConstraints] – in short, if it’s in AutoLayout and it’s annoying, PureLayout takes care of it. You’ll do the same work in half the code.
Best of all, that’s all PureLayout does; unlike some open source libraries, it doesn’t try and do too much. If you already know AutoLayout, the learning curve is about 5 minutes.
Are there any disadvantages to PureLayout? For very complex layouts, the ability to produce 17 constraints at once with constraintsWithVisualFormat might be preferable. Other than that, I can’t see any reason why you shouldn’t use PureLayout for all your layout needs.