Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
From the author of Building the Interface

Building the Interface

It's usually a good idea to begin a project by creating its interface. This approach allows you to experiment with the interface's design, making various changes without affecting your project's code. In the Project Navigator, click "MainMenu.xib" to display the interface editor. Xcode's AppleScriptObjC template includes a default window, so you don't need to create your own window. Click the "Window - HelloWorld" icon in the UI editor's left sidebar (see Figure 6) to open the empty window (see Figure 7).

Figure 6 Click this icon to display your project's main window.

Figure 7 The default project window.

In the search field at the bottom of the Object Library (Control-Option-Command-3), search for a Label element, and then drag it to the main interface window (see Figure 8).

Figure 8 Searching for a label interface element.

Double-click the label to edit it, and enter What's your name? as the label's text. Drag the label to the upper left of the main window and extend it to the right, if necessary. As you do this, guides appear in order to help you line up the object appropriately (see Figure 9).

Figure 9 Adding a label to the main window.

Next, search the Object Library for a Text Field element, drag it beneath the label in the main window, and adjust its size (see Figure 10).

Figure 10 Adding a text field to the main window.

Search the Object Library for a Button element, and then drag it to the main window beneath the text field. Adjust the button's size, if desired. Then double-click the button and change its text to Click Me. You may also want to adjust the size of the window itself at this time, using the displayed guides to assist with alignment (see Figure 11).

Figure 11 Adding a button to the main window.

  • + Share This
  • 🔖 Save To Your Account