You’re previewing Ry’s Cocoa TutorialUI Components

Buttons

A quick browse through the Object Library will show you that there are a lot of buttons included in the AppKit framework. Each one is designed for a different purpose, and it can be hard to know which button to use for any given situation. In this chapter, we’ll not only learn about how to configure these buttons, but also when certain buttons are more appropriate than others.

All buttons are represented by NSButton, and they use the target-action pattern described in the first chapter. The main configuration options are the Style and Type fields, which can be set in Interface Builder:

Configuring a button with the Style and Type fields

The vast number of type/style combinations can be overwhelming, so it helps to break them down into three main categories:

Some of the most common examples of these are shown below.

The three button categories

These groupings are based primarily on behavior, but within the first two categories, there are many different buttons defined by their appearance. We’ll explore all of these throughout this chapter.

Sorry, this is the end of the preview. To read the rest of this chapter, you’ll need to purchase Ry’s Cocoa Tutorial.

Mailing List

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.