Road Test: PureLayout

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.

PureLayout example

Write layout code like a frikking wizard! (From PureLayout example project)

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.


About Markk

Markk is an iOS developer.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s