I. Create a UIView
First step: Create
First look at the inheritance relationship, and then find this class has its own initialization method
UIView *view = [[UIView alloc] Initwithframe:cgrectmake (125, 125, 200, 200)];
Step Two: Set the background color by default is transparent
View.backgroundcolor = [Uicolor Cyancolor];
Step Three: Display the view on the window
[Self.window Addsubview:view];
The parent view manages its own child views through an array
Fourth Step: Release
[View release];
Because the parent view is placed into an array for management, the reference count +1,release, so we can add the view and then release the object, offsetting the resulting +1 of the alloc;
Two. Summary of knowledge points
1. A view has a parent view, but can have multiple child views
2. The coordinate starting point of the child view is relative to the 0,0 position of the parent view
3. Parent view can manage hierarchical relationships
[Self.window Bringsubviewtofront:view2];
[Self.window SENDSUBVIEWTOBACK:VIEW3];
4. Setting transparency
View3.alpha = 0.1;//Transparency (Transparency range 0.0 ~ 1.0, default is 1.0)
Beginner Ios-uiview