Auto Layout chains - chain based auto-layout constraint builder
This is ugly:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:view
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:otherView
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:0];
[view addConstraint:constraint];
Writing the same thing with ALChains:
ALChains(view)
.widthEqualToView(otherView)
.apply();
ALChains(view)
.widthEqualTo(300)
.heightEqualTo(180)
.apply();
ALChains(view)
.fill()
.apply();
ALChains(view)
.widthEqualTo(300)
.heightEqualTo(180)
.centerX(0)
.centerY(20)
.apply();
ALChains(view)
.widthEqualTo(100)
.heightEqualToView(otherView)
.adjacentRight(otherView, 10)
.apply();
Nothing more than a nice way of building and adding layout constraints to a view. It's pretty simple, might not cover all use cases, but i've found it pretty useful in my own projects.
Compatible with both iOS (UIView
) and Mac (NSView
) views.