Struct
Nsange:
Used to indicate the range
Create
Nsange R1 = {2, 4}
Nsange r2 = {. Location = 2,. Length = 4}
Nsange R3 = nsmakerange (2, 4)
Search for the range of a string in Str
Nsstring * STR = @ "I love OC ";
Nsange range = [STR rangeofstring: @ "Java"]
Nslog (@ "location = % lD, length = % lD", range. Location, range. length)
If not found, length = 0, location = nsnotfound =-1
Nspoint:
Used to represent the coordinates of a point
Create
Cgpoint p1 = nsmakepoint (10, 10 );
Nspoint P2 = cgpointmake (20, 20 );
Indicates the origin
Cgpointzero = cgpointmake (0, 0)
Nssize:
Indicates the size of a two-dimensional plane.
Nssize S1 = cgsizemake (100, 50 );
Nssize S2 = nsmakesize (100, 50 );
Cgsize S3 = nsmakesize (200, 60 );
Cgrect:
Represents a specific dimension and position of a two-dimensional plane.
Cgrectr1 = cgrectmake (0, 0,100, 50 );
Cgrect r2 = {0, 0 },{ 100, 90 }};
Cgrect R3 = {p1, S2 };
Another method for defining cgrect
Cgrect myrect (cgfloat X, cgfloat y, cgfloat width, cgfloat height)
{
Cgrect rect;
Rect. Origin. x = X;
Rect. Origin. Y = y;
Rect. Size. width = width;
Rect. Size. Height = height;
}
Convert struct to string
Nsstring * STR = nsstringfrompoint (P1 );
Nsstring * STR = nsstringfromsize (S3 );
Nsstring * STR = nsstringfromrect (R1 );
Compare whether the two points are the same (x, y)
Bool B = cgpointequaltopoint (cgpointmake (10, 10), cgpointmake (10, 10 ))
Determines whether a point is in a region.
Bool b2 = cgrectcontainspoint (cgrectmake (50, 40,100, 50), cgpointmake (60, 45 ))
The premise of using these cgpointequaltopoint, cgrectcontainspoint, and other functions is to add the CoreGraphics framework.
Black Horse programmer ___ Foundation _ struct