UIView *view1=[[uiview Alloc] Initwithframe:cgrectmake (50, 50, 100, 100)]; View1.backgroundcolor=[uicolor Yellowcolor]; view1.tag=1; [Self.window Addsubview:view1]; UIView *view2=[[uiview Alloc] Initwithframe:cgrectmake (10, 10, 20, 20)]; View2.backgroundcolor=[uicolor Greencolor]; view2.tag=2; view2.alpha=0.2;//change the transparency will affect the child view display [View1 addsubview:view2];//view nesting UIView *view3=[[uiview alloc] Initwithframe:cg Rectmake (10, 10, 30, 30)]; View3.backgroundcolor=[uicolor Graycolor]; view3.tag=3; [View2 addsubview:view3];//view 3 colors affected by the parent class UIView *view5=[[uiview Alloc] Initwithframe:cgrectmake (50, 50, 30, 30)]; View5.backgroundcolor=[uicolor Graycolor]; view5.tag=5; [View1 ADDSUBVIEW:VIEW5]; UIView *view4=[[uiview alloc] Initwithframe:cgrectmake (0, 0, 50, 50)]; View4.backgroundcolor=[uicolor Blackcolor]; view4.hidden=yes;//hides the view, also affects the sub-class [View1 ADDSUBVIEW:VIEW4]; UIView *view6=[[uiview Alloc] Initwithframe:cgrectmakE (80, 80, 10, 10)]; View6.backgroundcolor=[uicolor colorwithred:1 green:0 blue:0 alpha:0.5];//[View1 addsubview:view6]; UIView *view=[self.window viewwithtag:2];//Get the specified view via tag View.backgroundcolor=[uicolor Redcolor]; Custom View MyView *myview=[[myview alloc] Initwithframe:cgrectmake (150, 150, 100, 100)]; [Self.window Addsubview:myview]; [Self.window makekeyandvisible];
UIview Learning and Customizing--ios