Open Source Swift Library Allowing You To Create Complex Auto Layout Layouts from Code

Previously I mentioned the FLKLAutoLayout that allows you to easily create complex auto layouts from code.

Here’s an auto layout helper library created in Swift from Robert Böhnke inspired by FLKAutoLayout.

Cartography supports all of the auto layout attributes available in for auto layout in iOS 7, and to use it you simply need to supply Cartography with your views, and specify the different attributes within a closure making for a very clean readable syntax.

Here’s an example from the readme showing the syntax for Cartography:

layout(view1, view2) { view1, view2 in
    view1.width   == (view.superview!.width – 50) * 0.5
    view2.width   == view1.width – 50
    view1.height  == 40
    view2.height  == view1.height
    view1.centerX == view.superview!.centerX
    view2.centerX == view1.centerX

<pre><code>view1.top &gt;= view.superview!.top + 20
view2.top == view1.bottom + 20
</code></pre>

}

You can find Cartography on Github here.

A nice Swift library for working with auto-layout.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Open Source Swift Library Allowing You To Create Complex Auto Layout Layouts from Code

©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *