Basic properties of UIView in iOS

Source: Internet
Author: User

#import"AppDelegate.h"@interface appdelegate () @end @implementation appdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {Self.window=[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];; //320*568 5s//Create a 200-wide view that is added to the middle of the screen//The position of the view is relative to the origin of the left side of the parent view//UIView Important Attributes//1.frame contains Orgin (upper-left coordinate), Seze (size of rectangle)//The center point of the 2.center view relative to the parent view coordinate system//3.bounds changes, affecting the coordinate origin of its own coordinate system, thus affecting the position change of the sub-view//UIView *centerview = [[UIView alloc] Initwithframe:cgrectmake (60,184, $, +)];//[Self.window Addsubview:centerview];//Centerview.backgroundcolor = [Uicolor redcolor];//    //[Centerview release];//    //    //    //change the position of the Centerview relative to its own coordinate system//    //Centerview own position not all over, bounds change is centeview own coordinates origin point//    //causes the position of the Centerview Word view to change//centerview.bounds = CGRectMake (n , A, A, a);//    //    //    //Create a 100-wide view that is added to the middle of the screen//UIView *centerview1 = [[UIView alloc] Initwithframe:cgrectmake ((a);//[Centerview Addsubview:centerview1];//Centerview1.backgroundcolor = [Uicolor greencolor];//    //[CenterView1 release];//    UIView*centerview1 = [[UIView alloc] Initwithframe:cgrectmake ( -, -, -, -)];    [Self.window Addsubview:centerview1]; Centerview1.backgroundcolor=[Uicolor Redcolor];            [CenterView1 release]; UIView*centerview2 = [[UIView alloc] Initwithframe:cgrectmake ( -+ the, -+ the, -, -)];    [Self.window Addsubview:centerview2]; Centerview2.backgroundcolor=[Uicolor Greencolor];        [CenterView2 release]; UIView*CENTERVIEW3 = [[UIView alloc] Initwithframe:cgrectmake ( -+ the+ the, -+ the+ the, -, -)];    [Self.window ADDSUBVIEW:CENTERVIEW3]; Centerview3.backgroundcolor=[Uicolor Yellowcolor];            [CENTERVIEW3 release]; UIView*CENTERVIEW4 = [[UIView alloc] Initwithframe:cgrectmake ( -+ the, -+ the+ the+ the, -, -)];    [Self.window ADDSUBVIEW:CENTERVIEW4]; Centerview4.backgroundcolor=[Uicolor Graycolor];        [CenterView4 release]; UIView*CENTERVIEW5 = [[UIView alloc] Initwithframe:cgrectmake ( -, -+ the+ the+ the+ the, -, -)];    [Self.window ADDSUBVIEW:CENTERVIEW5]; Centerview5.backgroundcolor=[Uicolor Orangecolor];        [CENTERVIEW5 release]; //Print the parent view of the BrownviewNSLog (@"%@", Centerview1.superview); //Print a child view of a windowNSLog (@"%@", self.window.subviews); //Create a gray viewUIView *blackview = [[UIView alloc] Initwithframe:cgrectmake ( -, -, $, $)]; Blackview.backgroundcolor=[Uicolor Blackcolor];    [Self.window Addsubview:blackview]; //inserting a view into a specified position//[Self.window Insertsubview:blackview atindex:0]; //Under the specified view//[Self.window Insertsubview:blackview belowsubview:centerview1]; //on top of the specified view//[Self.window Insertsubview:blackview abovesubview:centerview1];[Blackview release]; //swap Two views//[Self.window exchangesubviewatindex:0 withsubviewatindex:1]; //move the view to the front//[Self.window Sendsubviewtoback:centerview1]; //move the view to the last face//[Self.window Bringsubviewtofront:centerview2]; //Delete the specified view//[CenterView2 Removefromsuperview]; //hierarchical relationships between views//1. The child view will definitely be in front of the parent view//2. After adding a view that has overlapping portions of the previous view, it overwrites the previous view//3. If you want to insert or change the hierarchical relationship of a view, you need the parent view to manage//4. Parent view manages hierarchical relationships of sub-views through arrays//5. If you want to remove from the parent view, remove it yourself for example [CenterView2 Removefromsuperview]; //Override point for customization after application launch.Self.window.backgroundColor =[Uicolor Whitecolor];    [Self.window makekeyandvisible]; returnYES;}

Basic properties of UIView in iOS

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.