Graphics Reference
In-Depth Information
.
CATextLayer
At first, this one is as surprising as the missing layout managers. But as we discuss in
greater detail, the UIView objects are fairly lightweight in themselves, and it is just
as easy to use a UILabel in the place of a CATextLayer .
Some of these items that are lacking can be quite frustrating, whereas others would clearly
be overkill on the device.
Building a Core
Animation Application
for Cocoa Touch
To demonstrate Core Animation on the
iPhone, we write an application similar to
the example we developed previously for
the desktop in Chapter 5, “Layer
Transforms.” In that example, we used a
UILabel and animated it in a star pattern.
The end result of the project for this
example is shown in Figure 13-1.
Setting Up the Xcode Project
Start this project by creating a new Cocoa
Touch project within Xcode and select
the Window-Based Application project
template, as shown in Figure 13-2.
1. Launch Xcode and create a new
project (Shift-
FIGURE 13-1
Star Label Animation
-N), and save it to
~/Documents/CAProjects . Name the
project Star.
Application
2. In Xcode, double-click the MainMenu.xib file to open it in Interface Builder.
3. From the Library panel, drag a Rounded Rect Button to the Window. In the Button
Attributes panel, enter Draw in the Title field to give the button a label.
4. Next, go back to the Library panel and drag a Label to the Window. Using the align-
ment guides, align the Label at the top-center part of the Window.
5. In the Label Attributes panel, enter Star in the Title field. When you do so, you
notice that the position of the word Star changes. To make this look a little better,
click the center alignment button in the Layout section to center-align the word
Star in the Window.
 
Search WWH ::




Custom Search