iPhone Application Development : Customizing Interface Appearance

10/12/2010 9:18:34 AM
How your interface appears to the end user isn’t just a combination of control sizes and positions. For many kinds of objects, literally dozens of different attributes can be adjusted. Although you could certainly configure things such as colors and fonts in your code, it’s easier to just use the tools included in Interface Builder.

Using the Attributes Inspector

The most common place you’ll tweak the way your interface objects appear is through the Attributes Inspector, available by choosing Tools, Attributes Inspector or by pressing Command+1. Let’s run through a quick example to see how this works.

Make sure that the EmptyView.xib file is still open and that you’ve added a text label to the view. Select the label, and then press Command+1 to open the Attributes Inspector, shown in Figure 1.

Figure 1. To change how an object looks and behaves, select it and then open the Attributes Inspector.

The top portion of the Attributes Inspector will contain attributes for the specific object. In the case of the text object, this includes settings such as font, size, color, and alignment—everything you’d expect to find for editing text.

In the lower portion of the inspector are additional inherited attributes. Remember that onscreen elements are a subclass of a view? This means that all the standard view attributes are also available for the object and for your tinkering enjoyment. In many cases, you’ll want to leave these alone, but settings such as background and transparency can come in handy.

Did You Know?

Don’t get hung up on trying to memorize every attribute for every control now—I cover interesting and important attributes when they are needed throughout the book.

Feel free to explore the many different options available in the Attributes Inspector, and to see what can be configured for different types of objects. There is a surprising amount of flexibility to be found within the tool.

By the Way

The attributes you change in Interface Builder are simply properties of the objects themselves. To help identify what an attribute does, use the documentation tool in Xcode to look up the object’s class and review the descriptions of its properties.

Setting Accessibility Attributes

For many years, the “appearance” of an interface meant just how it looks visually. Today, the technology is available for an interface to vocally describe itself to the visually impaired. The iPhone includes Apple’s screen reader technology: Voiceover. Voiceover combines speech synthesis with a customized interface to aid users in navigating applications.

Using Voiceover, a user can touch interface elements and hear a short description of what they do and how they can be used. Although you gain much of this functionality “for free” (the iPhone Voiceover software will read button labels, for example), you can provide additional assistance by configuring the accessibility attributes in Interface Builder.

To access the Accessibility settings, you need to open the Identity Inspector by choosing Tools, Identity Inspector or by pressing Command+4. The Accessibility options have their own section within the Identity Inspector, as shown in Figure 2.

Figure 2. Use the Accessibility section in the Identity Inspector to configure how the Voiceover interacts with your application.

You can configure four sets of attributes within this area:

Accessibility: If enabled, the object is considered accessible. If you create any custom controls that must be seen to be used, this setting should be disabled.

Label: A simple word or two that serves as the label for an item. A text field that collects the user’s name might use “your name,” for example.

Hint: A short description, if needed, on how to use the control. This is needed only if the label doesn’t provide enough information on its own.

Traits: This set of check boxes is used to describe the features of the object—what it does, and what its current state is.

Did You Know?

For an application to be available to the largest possible audience, you should take advantage of accessibility tools whenever possible. Even objects such as the text labels you’ve used in this lesson should have their traits configured to indicate that they are static text. This helps potential users know that they can’t interact with them.

Simulating the Interface

At any point in time during the construction of your interface, you can test the controls in the iPhone Simulator. To test the interface, choose File, Simulate Interface (Command+R). After a few seconds, the iPhone Simulator will start and display your interface design.

Watch Out!

When you use the Simulate Interface command, only the interface code is being run. Nothing that you may have written in Xcode is included. Therefore, you can simulate interfaces even if you haven’t written a single line of supporting code or if your code has errors. However, it also means that if your code modifies the display in any way, you won’t see those changes onscreen.

To compile and run your code along with the interface, switch to Xcode and click Build and Run, or, as a shortcut, choose File, Build and Go in Xcode from the IB menu (Command+Shift+R).

By the Way: Enabling the Accessibility Inspector

If you are building accessible interfaces, you may want to enable the Accessibility Inspector in the iPhone Simulator. To do this, start the simulator and click the Home button to return to the home screen. Start the Settings application and navigate to General, Accessibility, and then use the toggle button to turn the Accessibility Inspector on, as shown in Figure 3.

Figure 3. Toggle the Accessibility Inspector on.

By the Way

The Accessibility Inspector adds an overlay to the simulator workspace that displays the label, hints, and traits that you’ve configured for your interface elements. Note that navigating the iPhone interface is very different when operating in accessibility mode.

Using the X button in the upper-left corner of the inspector, you can toggle it on and off. When off, the inspector collapses to a small bar, and the iPhone simulator will behave normally. Clicking the X button again turns it back on. To disable the Accessibility Inspector altogether, just revisit the Accessibility setting in the Settings application.

  •  iPhone Application Development : Creating User Interfaces
  •  iPhone Application Development : Understanding Interface Builder
  •  Android Security Tools
  •  Android Security : Binder Interfaces
  •  Android Security : Files and Preferences
  •  Android Security : ContentProviders
  •  Android Security : Services
  •  Android Security : Broadcasts
  •  Android Security : Activities
  •  Android Security : Creating New Manifest Permissions
  •  Android Permissions Review
  •  Android’s Security Model
  •  Android’s Securable IPC Mechanisms
  •  CSS for Mobile Browsers : CSS Techniques
  •  CSS for Mobile Browsers : Selectors
  •  CSS for Mobile Browsers : Where to Insert the CSS
  •  iPhone Programming : Creating a Table View
  •  iPhone Programming : Simplifying the Template Classes
  •  Mobile SEO
  •  Building Android Apps : Adding Basic Behavior with jQuery
    Top 10
    Western Digital Black 4TB - One Of The Quickest Physical Drives
    Xigamtek Midgard II - An Affordable Chassis
    Multifunction Printer Group Test (Part 2) : Epson Stylus Photo PX730WD, HP Photosmart 5520 e-ALL-in-ONE
    Multifunction Printer Group Test (Part1) : Canon Pixma MG2250, Canon Pixma MX895
    HP Photosmart 7520 e-All-in-One
    Viewsonic Pro8300 - Full HD 1080p DLP Projector
    Best TV Designs Of 2012
    Scan 3XS Sniper FT03 Nanu - Compact Gaming Systems
    Corsair Carbide 200r - Joy To Build
    Amazon Isn’t Just For Books Anymore...
    Most View
    Joomla! Blogging and RSS Feeds : Using separate blog components
    iPhone Application Development : Getting the User’s Attention - Exploring User Alert Methods
    Architecting Applications for the Enterprise : UML Diagrams (part 1) - Use-Case Diagrams
    Philips 7000 Series 46PFL7007
    Hacking - Nonexecutable Stack
    Toshiba AT200-101
    Install Windows Vista Home Premium SP2 Fail, What Should We Do?
    DSLR Test – Full Filling
    Windows Server 2008 : Manage Hyper-V Remotely
    Windows Phone 7 Advanced Programming Model : Advanced Data Binding (part 2) - Syndicated Services
    Evga GTX 690 - Hail To The King
    Remote Administration of Exchange Server 2010 Servers : Using the ECP Remotely
    Primer – Choosing And Using Peripheral Buses (Part 1)
    Microsoft & Apple rejoin the os battle
    Secure Your Smartphone (Part 1)
    SQL Azure : Tuning Techniques (part 2) - Connection Pooling & Execution Plans
    ASUS Radeon HD 7950 : is not only powerful, but also energy saving
    Workgroup All-In-One : Samsung Clx-6220fx
    Configuring A Child - Friendly iPad
    Creating and Managing Views in SQL Server 2008 : Indexed Views