Tails alternatives and similar libraries
Based on the "Auto Layout" category
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Tails or a related project?
Tails is a take on declarative Auto Layout. If you don't like typing (like me), it might be your kind of thing!
Tails is written in Swift and currently supports iOS only. OSX support is coming soon.
Meet the tail operator (™):
~. It lets you use your views in fully fledged layout equations. All you need to do is grow them little tails:
Tails.install( view1~.top == self.topLayoutGuide~.bottom, view1~.left == view1.superview~, view1~.width == 50, view2~.top == view1~, view2~.trailing == view1~.leading + 10, view2~.width >= view1~ * 2 )
Things become really cool with composite layout attributes:
Tails.install( view1~.size == CGSize(width: 60, height: 40), view1~.center == view2~ - CGPoint(x: 0, y: 20), view2~.edges == view2.superview~, view3~.top.left.width == view1~ )
NSLayoutAttribute values are available in Tails, as such:
It is possible to use multiple attributes in the same equation by simply chaining them:
top.left. There are several predefined composed ones:
You may omit right side attributes to infer them from the left side of equation:
Tails.install( headerView~.top.left.right == containerView~ )
Layout constants in Tails are not limited to scalar values. It is possible to use such structs as
UIEdgeInsets. They only affect specific layout attributes:
For instance, this code:
let insets = UIEdgeInsets(top: 10, left: 20, bottom: 40, right: 20) Tails.install( view~.top.left.right == superview~ + insets, view~.bottom == footerView~.top + insets )
Is equivalent to:
Tails.install( view~.top == superview~ + 10 view~.left == superview~ + 20 view~.right == superview~ - 20 view~.bottom == footerView~.top - 40 )
~~ operator to specify constraint priority:
Tails.install( view1~.width <= view2~ ~~ UILayoutPriorityDefaultLow )
Tips and tricks
For alignment attributes, you may omit the right side view to refer to the left superview:
let insets = UIEdgeInsets(...) Tails.install( view~.edges == insets // same as view~.edges == view.superview~.edges + insets )
- OSX support
- Tests (yeah, I know)
- More examples
- Constraint manipulation