What Is Autolayout?
Previously in iOS, designing fluid resize-able layouts was difficult. It involved a lot of computation on behalf of an app programmers. Which meant the programming/designing cycle could be quite long. Even worst, a designer might suggest something a programmer wouldn’t have anticipated and achieving the design would mean rewriting lots of code.
Autolayout is what is referred to as a constraint based layout system for iOS apps. Put simply you tell iOS that you want a button to be roughly in a location and to be about a certain size and you can leave the layout system do all the rest of the work. If you want a button to be near the bottom of the screen and take up about 90% of the width of the screen, you can achieve that easily enough. What’s better is that when you change the screen size or even screen orientation (which is very common on mobile devices), the layout copes with this and resizes everything to be the right proportions.
In ways it probably sounds familiar to web developers, because of the responsive design trends that have appeared over the years on the web. Constraint based layout systems aren’t new, not by any stretch of the imagination. There are papers going back to the a famous computer science conference OOPSLA ‘88 that talk about building GUIs using constraint based layout.
Autolayout is a well tested and well worn way of making UIs when you know you need to target very different screen sizes, which all iOS apps need to do nowadays.
Links
- Apple Developer Documentation, “Understanding Auto Layout”.
- Wikipedia Article on the Cassowary Constraint Solving Toolkit as design by by Greg Badros and Alan Borning.
- “A smalltalk window system based on constraints” by Danny Epstein & Wilf R. LaLonde (1988)