IOS development note _ 1. Introduction to the basic system of uiwindow and uiview

Source: Internet
Author: User

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.

 

Related Article

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.