UI development----UIView and uilable

Source: Internet
Author: User

Created by Guo Chai April 10, 2015 17:48:32

Buy two tickets today, Sunday home Sunday back! No matter what, please remember: there I am!! !

Wish: God bless Guo Home!!!

==========================================================================

Windows window:

window is the window, each app needs to show the content to the user through window.
In iOS, let's use the UIWindow class to table the window, usually? One should? Use a program to create only one UIWindow object.
The main use of window is to render the content to the user, we do not do too much for window.

Create window:

Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];
Import Screen:

Self.window.backgroundColor = [Uicolor Yellowcolor]; [Self.window makekeyandvisible];

UIView:

The steps to create a view are as follows:

? 1, open up the space and initialize the view (when initializing, give the view location and?????). 2, do the view? Some settings (? for example: Background color)? 3. Add the view to window to make a positive display?
4. Releasing the View object

UIView *blueview = [[UIView alloc]initwithframe:cgrectmake (+, +, +)];blueview.backgroundcolor = [Uicolor] Bluecolor]; [Self.window Addsubview:blueview]; [Blueview release];

The coordinate system is not based on the pixel, but the "point" as the basis.


Frame:

Frame is an important attribute of view, which is the key to the layout of our views, which determines the size and position of the view.

Frame is a structure that contains 2 parts: Origin and size. So is Origin? A struct containing 2 parts: X and Y. Size is the same? A struct that contains 2 sections: Width and height. The origin and size of frame are relative to the parent view. The CGRectMake () function can help us quickly construct a cgrect variable.

Center:

Center (central ⼼) is also an important attribute of view.
Center is a structure that contains 2 parts: X and Y.
Center has a close relationship with frame.
Bounds:

Bounds (boundary) is also an important attribute of view, which is used to define the boundaries of self-own. it with
Frame? A cgrect struct variable.

When the child view is added to this view, the frame is calculated according to the origin point specified by bounds (0,0), and not the upper left corner.

===============================

Some view methods:

  UIView * Aview = [[UIView alloc] Initwithframe:cgrectmake (ten, +, +)];//aview.backgroundcolor = [Uicolor gree  ncolor];//[Self.window addsubview:aview];////UIView * bview = [[UIView alloc] Initwithframe:cgrectmake (30, 40,  ];//Bview.backgroundcolor = [Uicolor redcolor];//[Self.window addsubview:bview];//////UIView *     CView = [[UIView alloc]initwithframe:cgrectmake (+, +, +)];//cview.backgroundcolor = [Uicolor orangecolor];// Insert View view////[Self.window insertsubview:cview atindex:1];////[Self.window Insertsubview:cview aboveSubview:a    view];//[Self.window Insertsubview:cview belowsubview:bview];////[Self.window bringsubviewtofront:aview];// [Self.window sendsubviewtoback:aview];////switch position when the coordinates have not changed//[Self.window exchangesubviewatindex:0 Withsubviewatindex:2]    ; Remove child view//[Aview removefromsuperview];////Remove all views//for (UIView * view in Self.window.subviews) {//[vie W Removefromsuperview];//}////Aview.hidden = yes;//Aview.hidden = no;////Set Transparency range 0-1, 0 for transparent//Bview.alpha = 0.7;/// /Get parent view of child view///UIView *superview = [Aview superview];////Get all child views of this view////Nsarray * views = [Self.window Subvie ws];////Add tag to view//Aview.tag = 100;//UIView * v = [Self.window viewwithtag:100];//v.backgroundcolor = [Uico Lor purplecolor];////[Aview release];//[bview release];//[CView release];


Uilable:

UILabel (label): A control that shows the text of a display. In the app, Uilabel is the frequency
The most high-rate control. Uilabel is UIView? Subclass, as a subclass? Generally, to augment the functionality of the parent class,
Uilabel extended the function of the text display, the Uilabel is a view of the text that can be displayed.

Creation of uilable:

   UILabel *usernamelabel = [[UILabel alloc]initwithframe:cgrectmake (+, +, +)];usernamelabel.text = @ "? username"; [Containerview Addsubview:usernamelabel]; [Usernamelabel release];
Common methods of Uilable:

    UILabel * lable = [[UILabel alloc] Initwithframe:cgrectmake (+, +, (+))];    Set text content    Lable.text = @ "Hellow Guo Chai! haha haha haha haha haha haha ";    Sets the number of rows lable    lable.numberoflines = 0;    Set text color    lable.textcolor = [Uicolor redcolor];    Alignment    lable.textalignment = Nstextalignmentcenter;    lable font size    Lable.font = [Uifont systemfontofsize:12];    Set Shadow color    Lable.shadowcolor = [Uicolor greencolor];    Set the shadow offset    lable.shadowoffset = Cgsizemake (2, 2);


Summary:

Does the app display content by window? A program? Generally only creates a window.
The elements that can be seen in the app are UIView and its subclasses.
UIView as a baseclass for all visual controls, provides a number of properties and methods. Display effect control (frame, alpha, etc.), view addition and removal (addsubview: etc.), view level adjustment (Bringsubviewtofront: etc.), etc.
Uilabel belongs to the specific view, has the self-own focus


===========================================================================

Listen to favorite songs, do like things, chase like people, simple happiness!!!

-------Guo Chai



UI development----UIView and uilable

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.