iOS Learning (UI) Knowledge Point Grooming
First, about the introduction of UIView
1) Concept: UIView is a large container for loading and displaying various types of controls, which is the base class for all UI controls in iOS
2) UIView Initialization of the instance code
1UIView *view1 =[[UIView alloc] init];2View1.frame = CGRectMake (0, -, Self.view.frame.size.width, self.view.frame.size.height/2);3View1.backgroundcolor =[Uicolor Lightgraycolor];4View1.tag = +;5 6 //Alpha Property Sets the transparency of the view7View1.alpha =0.5;8 9 //Out-of- section Auto-HideTenView1.clipstobounds =YES; One[Self.view Addsubview:view1];
3) Sendsubviewtoback The parent view can use the Sendsubviewtoback method to place the child view at the bottom
for example:
1 UIView *view3 = [[UIView alloc] init]; 2 view3.frame = CGRectMake (45 , 45 , 240 , 260 ); 3 view3.backgroundcolor = [Uicolor Bluecolor]; 4 View3.tag = ; 5 [View1 ADDSUBVIEW:VIEW3]; 6 //
8 [View1 SENDSUBVIEWTOBACK:VIEW3];
4) Bringsubviewtofront Parent view You can use the Sendsubviewtoback method to place child views on top of the hierarchy
for example:
1 UIView *view2 = [[UIView alloc] init]; 2 view2.frame = CGRectMake (40 , 40 , 250 , 250 ); 3 view2.backgroundcolor = [Uicolor Blackcolor]; 4 View2.tag = ; 5 [view1 Addsubview:view2]; 6 // 8 [View1 BRINGSUBVIEWTOFRONT:VIEW2];
5) Get all the sub-views in Self.view for example:
1 Nsarray *subviews = self.view.subviews;
6) Removefromsuperview Remove the child view from the parent view for example:
1 [View1 Removefromsuperview];
7) Viewwithtag Gets the view based on the view tag tag, for example:
1 UIView *view = [Self.view viewwithtag:+];
8) Hidden hidden view for example:
1 View.hidden = YES;
9) Because all controls inherit from UIView, you can use Viewwithtag to get the control object based on the tag tag of the control
For example:
1 // 1000 Tag tags for button note: Need a strong turn 2 UIButton *button= (uibutton*) [Self.view viewwithtag:+];
iOS Stage Learning 28th Day notes (UIView's introduction)