Basic concepts of Windows and views

Source: Internet
Author: User

I. The relationship between Uiwindow1.uiwindow and UIView

(1) UIWindow is a subclass of UIView, which provides the display area of the view;

(2) UIWindow inherits from UIView, which contains the viewable area of the application.

Creation of 2.UIWindow
    //1. Get the screen sizeUIScreen *screen=[UIScreen mainscreen]; CGRect rect=Screen.bounds; //2. Create a window and fill the entire screenself.window=[[UIWindow alloc] initwithframe:rect]; //3. Add a background color to the windowSelf.window.backgroundcolor=[uicolor colorwithred:1.0Green1.0Blue0.0Alpha1.0]; //Self.window.backgroundcolor=[uicolor Whitecolor]; //4. Display window[Self.window makekeyandvisible];

Second, iOS coordinate system 1. Create views View
    //Create a view v0,v0 as a child of UIWindowUIView *v0=[[uiview Alloc] Initwithframe:cgrectmake ( -, -, $, $)]; V0.backgroundcolor=[Uicolor Bluecolor];        [Self.window Addsubview:v0]; //Create a view v1,v1 as a child of UIWindowUIView *v1=[[uiview Alloc] Initwithframe:cgrectmake ( -, -, $, $)]; V1.backgroundcolor=[Uicolor Redcolor];        [Self.window ADDSUBVIEW:V1]; //Create a view v2,v2 as a child of UIWindowUIView *v2=[[uiview Alloc]initwithframe:cgrectmake ( Max, Max, $, $)]; V2.backgroundcolor=[Uicolor Greencolor]; [Self.window Addsubview:v2];
2.frame, bounds, center of the relationship

Frame: Represents the position and size of the view in the parent view's coordinate system.

bounds: Represents the position and size of the view in its own coordinate system .

Center: Represents the midpoint position of the view in the parent view's coordinate system.

Note: Changing one of the properties affects the other two.

    V2.frame = CGRectMake (00); //   V1.center = cgpointmake (+); //   v1.bounds = CGRectMake (0, 0, $, +); //   v1.frame = CGRectMake (max, Max, ten, +);

Basic concepts of Windows and views

Related Article

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.