Cleaning up with Auto Layout

Your application has a usability issue: The user can resize the application window, but the instance of DieView will stay its original size. What you want is for the DieView to resize along with its superview. You can fix this with Auto Layout.

Auto Layout is a sophisticated system for controlling the layout of views in a window by applying constraints to views. You will learn more about Auto Layout and constraints in Chapter 25.

In this section, you are going to skip ahead and apply a constraint to make DieView resize with the window. The constraint will keep all four edges of the DieView exactly 20 points away from the edges of its superview (the content view of the window). Thus, when the window is ...

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.