You’re previewing Ry’s Cocoa Tutorial
Creating static layouts in Interface Builder is fairly straightforward: you simply drag UI components around the Editor Area. But, as soon as you incorporate window resizing, building layouts gets a lot trickier. Instead of just setting the position and size of each view, you also need to define how they stretch, shrink, or re-position themselves when the user resizes the window.
Correctly implementing this behavior is a very important part of the user experience. Think about how many times you’ve dragged the corner of a window to make it bigger or smaller. Sometimes you want a tiny window that can be displayed alongside other apps, while other times you want a full-screen experience. As a developer, it’s important to make sure your app looks good in both use cases.
Cocoa provides two distinct layout paradigms to solve this problem: Autoresizing Masks and Auto Layout. Autoresizing masks are also known as the “springs and struts” model. They’re much simpler to use than Auto Layout, but they aren’t nearly as flexible. The purpose of both these paradigms is to let you intuitively define a UI in Interface Builder that automatically adapts to different window sizes.
Sorry, this is the end of the preview. To read the rest of this chapter, you’ll need to purchase Ry’s Cocoa Tutorial.
Sign up for my low-volume mailing list to find out when new content is released. Next up is a comprehensive Swift tutorial planned for late January.
You’ll only receive emails when new tutorials are released, and your contact information will never be shared with third parties. Click here to unsubscribe.