If you write code using Auto Layout, you will have noticed by now that the structure of the code from using NSLayoutConstraint
isn't that readable once you have a few more UI elements.
Cartography by Robb Böhnke changes that by introducing a declarative manner to specify Auto Layout constraints in Swift.
This is an example given in the README:
layout(view1, view2) { view1, view2 in
view1.width == (view1.superview!.width - 50) * 0.5
view2.width == view1.width - 50
view1.height == 40
view2.height == view1.height
view1.centerX == view1.superview!.centerX
view2.centerX == view1.centerX
view1.top >= view1.superview!.top + 20
view2.top == view1.bottom + 20
}
If you are working with Objective C, also look at FLKAutoLayout by Florian Kugler.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.