Get Updates By E-mail 

Article Written By:
Johann Dowa

Library Making iOS 6 Auto-Layout Extremely Easy To Use Programmatically

The auto layout feature added in iOS 6 is terrific, but could definitely be easier to work with especially from code.

Here’s a library called Keep Layout by Martin Kiss designed to do just that – make auto layout easy to use from your objective-c code.

As the readme states:

Keep Layout is project under active development whose purpose is to make Auto Layout easy to use from code! No more clicking in Interface Builder or manual creation of constraints. Think in attributes and their rules. Keep Layout will set all constraints to keep your desired layout.

Keep Layout provides a number of attributes and rules that you can set to configure auto-layout making it dead easy to use from code.

You can easily set the dimensions, aspect ratio, alignment, and more and adjust the priority of each rule.

Here’s a simple example of how you’d use the KeepEqual rule to keep the width of a view at exactly 150 px from the readme:

[view keep:[KeepWidth rules:@[ [KeepEqual must:150] ]];
// view must keep width of 150pt

You can find Keep Layout on Github here.

Makes auto-layout dead simple to set up without interface builder.

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.