This chapter introduced the core concepts that underpin Auto Layout, Cocoa’s declarative constraint-based descriptive layout system. You learned that Auto Layout focuses on the relationships between views, and between views and their content, instead of on their frames. A logical priority-based framework drives Auto Layout. You discovered that its rules must be satisfiable, consistent, and sufficient. Here are a few final thoughts to take away with you from this chapter:
- Constraints are fun and powerful, and they provide elegant solutions to common layout situations. Do not be put off by Interface Builder’s layout editor, which can be disappointing for nontrivial layout; constraints are brilliant!
- Don’t be afraid to mix and match Auto Layout and Autosizing. So long as their rules do not conflict, you may port your existing layouts to a new world.
- Auto Layout is more than just constraints. Its content-protecting features provide a key component that helps specify what to show and not just where to show it. Compression resistance and content hugging play major roles in adapting graphical user interfaces (GUIs) during internationalization. When languages change, labels can vary widely in size.
- Several projects are underway attempting to backport Auto Layout to iOS 5 and earlier. Search around the Web for details. None of these projects have made significant headway yet, but they’re worth keeping an eye on.