Early this year I mentioned a library called Keep Layout designed to make Auto Layout easy to use from code.
Florian Kugler has created a library called FLKAutoLayout allowing you to easily set up auto layout using a nice readable syntax, simple predicated statements (ie. “>=300, <=500”) and with some extra features for more complicated layouts.
Here’s a code example from the readme demonstrating how easy it is to use FLKAutoLayout:
[labels alignTop:@"20" leading:@"20" toView:labels.superview];
// give it a minimum width of 200 and a maximum width of 300
// now constrain all labels to this size
// space the labels out vertically with 10 points in between
[UIView spaceOutViewsVertically:labels predicate:@"10"];
// now let's take care of the text fields.
// the first one has a fixed space of 20 to its label
[textFields constrainLeadingSpaceToView:labels predicate:@"20"];
// constrain the right edge to its superview with 20 points padding
[textFields alignTrailingEdgeWithView:textFields.superview predicate:@"20"];
// constrain all other text fields to the same width
// and finally let's align the baseline of each label with the baseline of each text field
[UIView alignAttribute:NSLayoutAttributeBaseline ofViews:labels toViews:textFields predicate:nil];
You can download FLKAutoLayout on Github here.
You’ll find a nice usage example included.
A very nice library for creating complex layouts with concise and readable code.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.