Uiview is the base class of the view.
A window is a base class of a view. The main function of a window is to provide a certain area to display the view. 2. Distribute events to the view.
The window itself does not have any content. For applications, it only provides a basic container. The view defines the content you want to use and fills in part of the window. For example, a view that displays images, text, shapes, or combinations can be used to organize and manage other views.
A window is usually represented by an instance of the uiwindow class. uiwindow inherits the uiview.
IOS Coordinate System
Before talking about uiview, let's first talk about the IOS coordinate system. The IOS coordinate system is used as the origin point from the upper left corner of the screen.
Cgpoint * point = cgpointmake (x, y); // obtain the location
Cgsize * size = cgsizemake (width, height); // get the size
Cgrect rect = cgrectmake (X, Y, width, height); // position and size
Frame and bonds
Frame starts with a parent view and obtains its own location information.
Bonds starts with the coordinates of the IOS system. The coordinates are (0, 0 );
Center indicates the position of the View Center. This attribute can change the view position.
Create a uiview
// Create nsbundle * bundle = [nsbundle mainbundle] through the XIB file; nsarray * array = [bundle loadnibnamed: @ "myview" Owner: Self options: Nil]; // XIB file name uiview * myview = [array objectatindex: 0]; // Code creates cgrect viewrect = cgrectmake (0, 0,200,200); uiview * myview = [[uiview alloc] initwithframe: viewrect];
Search View
The uiview class has a tag attribute, which is an integer that can mark a view object.
Obtain viewwithtag: retrieve the marked subview.