Official address:
http://developer.apple.com/library/ios/#documentation/graphicsimaging/reference/cggeometry/reference/reference.html
1. Data type:
cgfloat: Basic types of floating-point values
Cgpoint: Represents a point in a two-dimensional coordinate system
cgsize: Represents the width and height of a rectangle
CGRect: Represents the position and size of a rectangle
typedef float CGFLOAT;//32-bittypedef Double cgfloat;//64-bitstruct cgpoint { cgfloat x; CGFloat y;}; typedef struct CGPOINT cgpoint;struct cgsize { cgfloat width; CGFloat height;}; typedef struct CGSIZE cgsize;struct CGRect { cgpoint origin; Cgsize size;}; typedef struct CGRECT CGRect;
Note: The height and width of the CGRect data structure can be negative. For example, the origin of a rectangle is [0.0,0.0] and the size is [10.0,10.0]. The rectangle that is exactly the same as the origin is [10.0,10.0] and the size is [ -10.0,-10.0] of the rectangle.
2. Methods for creating geometric elements using values
Cgpointmake
CGRectMake
Cgsizemake
Cgpoint Cgpointmake ( cgfloat x, cgfloat y); Cgsize Cgsizemake ( cgfloat width, cgfloat height); CGRect CGRectMake ( cgfloat x, cgfloat y, cgfloat width, cgfloat height);
CGFloat ten=10.0f; Cgpoint point = Cgpointmake (0.0f, 0.0f); Cgsize size = Cgsizemake (10.0f, 10.0f); CGRect rect = CGRectMake (Point.x, Point.y, Size.width, size.height); NSLog (@ "Ten:%f", ten); NSLog (@ "point:%@", Nsstringfromcgpoint (point)); NSLog (@ "Size:%@", nsstringfromcgsize (size)); NSLog (@ "rect:%@", Nsstringfromcgrect (rect));
Reproduced.
OC basic data type, Cggeometry class defines the structure of geometric elements and functions for manipulating geometric elements