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