Auto Layout
Auto Layout is a system that allows developers to create responsive user interfaces. It was introduced with iOS 6, and is the preferred method for creating layouts with UIKit.
Historically, frame-based layouts allowed developers to have fine tuned control of their user interfaces. However, frame-based layouts began causing issues when apps needed to support different screen sizes. Apple introduced Auto Layout for this reason. Bart Jacobs explains this issue here:
"... frame-based layouts cause a lot of headaches if your application runs on devices with different form factors. This wasn't a problem in 2007 when Apple introduced the original iPhone with its 3.5-inch screen. Nowadays, however, applications need to look great on a wide variety of devices with a mix of screen sizes. The message is simple, avoid frame-based layouts whenever possible."
With Auto Layout, constraints define relationships between views. Constraints are much more flexible than frame-based and autoresizing layouts. These constraints are used to dynamically size the frame of each view. This means the developer never needs to explicitly size a view's frame. As a result, Auto Layout user interfaces are dynamic and look correct on a variety of screen sizes and orientations.
Further Reading
Auto Layout is a powerful tool that every iOS developer should know. In this series of posts, we'll discuss Apple's Auto Layout framework in long form. We'll cover the following topics:
- Anchors and Layout Guides
- Intrinsic Content Size
- StackViews
- Adaptive Layout