Common elements in the development of iOS interfaces

Source: Internet
Author: User

Cgpoint, Cgsize, CGRect, cgrectmake, window, view simple records in interface development

    • Defined
/**/    struct  cgpoint {    cgfloat x;    CGFloat y;  };   struct Cgpoint Cgpoint;  
/**    struct  cgsize {    cgfloat width;    CGFloat height;  };   struct Cgsize cgsize;  
/**/    struct  cgrect {    cgpoint origin; // offset is relative to  the parent window   cgsize size;  };   struct CGRect CGRect;  

    • Common functions

Cgpoint cgpointmake ( cgfloat x, cgfloat y );

CGRect cgrectmake ( cgfloat x, cgfloat y, cgfloat width, cgfloat height );

Set origin (starting point, upper left corner), width and height, you can draw a rect (rectangle) with a position and size OK, this function is declared as an inline function

Cgsize cgsizemake ( cgfloat width, cgfloat height );

CGRect screenbounds = [[UIScreen mainscreen]bounds]; // returns a Rect  with the status bar CGRect viewbounds = [[UIScreen mainscreen]applicationframe]; //   rect that does not contain a status bar
Cgrectlnset (Arect) is used to create smaller or larger rectangles (the same center point). Use positive inline values to represent smaller rectangles, and negative inline values for larger rectangles. Cgrectintersectsrect (Rect 1.feet 2) can determine whether a rectangular structure crosses, and whether two rectangular objects overlap. Cgrectzero is a rectangular constant with a height and width of zero and is located at (0,0).  You can use this constant when you need to create a border but are unsure about the size or position of the border. Cgrectoffset creates a rectangle using the origin offset from the source CGRect
float 25.0  = CGRectMake (n= cgrectoffset (r1, offset, offset);


Cgrectintersectsrect allows us to determine if two rectangles intersect
    float 25.0 ;     = CGRectMake (+ +);     = CGRectMake ();     if (Cgrectintersectsrect (R1, r2))    {        NSLog (@ "intersecting");    }
Nsstringfromcgrect can be used to display the CGRect to the console
    CGRect r1 = CGRectMake (+);    NSLog (@ "rect:@%", Nsstringfromcgrect (R1));   
Similarly, cgrectfromstring allows us to create a cgrect based on a string:
    @" {0,0},{100,100} " ;     = Cgrectfromstring (R);

View
uiview* MyView =[[UIView alloc]initwithframe:cgrectmake (0.0,0.0,200.0,400.0 )]; // This creates a canvas that defines the position relative to the parent window, as well as the size.

Self.window = [[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; = [Uicolor graycolor]; // set a background color for window
    • Transformation
The standard Coregraphics call transforms the view in real time. For example, you can apply clipping, rotation, or other plane geometry effects. The Cocoatouch supports a complete set of affine transformations (conversion, rotation, scaling, tilt, etc.).      The DrawRect: Method of any UIView subclass provides an entry point for drawing through a low-level core graphics call. Note When calling the core graphics function, remember that quartz establishes a coordinate system from the lower left, while the origin of Uiviews is located in the upper-left corner. Each view has a translucent feature (Alpha) whose value is between opaque and transparent. It can be adjusted by [MyView Setalpha:value] with an alpha value between 0.0 (fully transparent) and 1.0 (completely opaque). You can specify a color for the view background. [MyView Setbackgroundcolor:[uicolor Redcolor]) to set the view to red.
    • Status bar

Whether you use landscape or portrait mode, the standard status bar at the top of the screen occupies a height of 20 pixels. To query the status bar border, you can call [[UIApplication sharedapplication] statusbarprame].

If you prefer to free up this 20-pixel screen space, you can completely hide the status bar. Use this uiapplication call: [UIApplication sharedapplication]setstatusbarhidden:yes Animated:no]. Or, set Uistatusbarhidden to <true/> in the application's Info.plist file.

To run the application only in landscape mode, you can set the status bar orientation to landscape. You should also do this if you plan to hide the status bar (that is, [[Uiapptication sharedapplication] Setstatusbarorientation: Uiineerfaceorientationlandscaperight]).      This will force the window to display the right side of the horizontal keyboard. The UIScreen object represents the physical screen of the iphone ([UIScreen Malnscreen]). This screen object establishes a mapping between the view layout boundary and the pixel space. It returns a full-screen size (bounds) or just an application-occupied rectangle (applicationframe).      The status bar and the size of any toolbar/navigation bar (if used) are considered later. By default, Uinavigationbar, Uitoolbar, and Uitabbar objects have a height of 44 pixels. Use these numbers to calculate the free space on your iphone screen, and to lay out your application when you are not using the Interface Builder Layout tool

Common elements in the development of iOS interfaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.