For the More Curious: Autoresizing Masks

Before Auto Layout, Cocoa developers used autoresizing masks to handle dynamic layout. An autoresizing mask defines how a view resizes in response to its superview resizing. Unlike Auto Layout, autoresizing masks do not provide any means of defining a view’s relationship with its sibling views, changing content as with the intrinsic content size, or animating changes.

An autoresizing mask is made up of springs and struts. Springs allow the view to resize in the horizontal and/or vertical directions. Struts preserve the distance between the sides of the view and its superview. It is called a mask because it is expressed as a bit field. Figure 25.16 and Figure 25.17 demonstrate two typical ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.