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:
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 >= 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.
- Open Source Library For Easily Creating Complex Auto Layout Layouts From Code
- Handy UIView Category Providing Layout Helper Methods (Z-Ordering, Absolute Positioning And More)
- Tutorial: A Series Of Examples On Using The iOS Auto-Layout Feature Programmatically
- Library Making iOS 6 Auto-Layout Extremely Easy To Use Programmatically
- Open Source Component Providing A UICollectionView Layout With Drag And Drop Re-ordering
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.