Alignment Rectangles

Constraints take a different approach to frames than do traditional manual layout. Frames describe where to place views on the screen and how big those views will be. When laying out views, constraints use a related geometric element called an alignment rectangle.

As developers create complex views, they may introduce visual ornamentation such as shadows, exterior highlights, reflections, and engraving lines. As they do, these features usually become attached as subviews or sublayers. As a consequence, a view’s frame, its full extent, grows as items are added.

Unlike frames, a view’s alignment rectangle is limited to a core visual element. Its size remains unaffected as new items join the primary view. Consider Figure 5-1 ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.