iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch
by Maher Ali
Chapter 4. The View
This chapter explains the main concepts behind views. You will learn about view geometry in Section 4.1. In Section 4.2, we cover the topic of view hierarchy. Next, Section 4.3 discusses, in great detail, the multitouch interface. In this section, you will learn how to recognize multitouch gestures. After that, we discuss several animation techniques in Section 4.4. Finally, Section 4.5 deals with how to use Quartz 2D functions for drawing inside a view.
View Geometry
There are three geometric properties of the UIView class that you need to understand. These properties are: frame, bounds, and center. Before explaining these properties, let's first look at some of the structures and functions used in specifying the values for these properties.
Useful geometric type definitions
The following types are used throughout the text:
CGFloatrepresents a floating number and is defined as:typedef floatCGFloat;CGPointis a structure that represents a geometric point. It is defined as:structCGPoint { CGFloat x; CGFloat y; };typedef structCGPoint CGPoint;The
xvalue represents the x-coordinate of the point and theyvalue represents its y-coordinate.You will use
CGPointa lot.CGPointMake() is a convenient function defined to make aCGPointfrom a pair ofxandyvalues, and is defined as follows:CGPoint CGPointMake ( CGFloat x, CGFloat y );
CGSizeis a structure used to represent width and height values, and is declared as follows:structCGSize { CGFloat width; CGFloat height; ...