iOS Development-ui (i) Supplemental UIWindow UIView UIlabel

Source: Internet
Author: User

Forget to put these out, now add, should be placed in front of the study

Knowledge Points:

Preliminary understanding of 1.UI

2.UIWindow

3.UIView

4.UIlabel

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

A preliminary understanding of UI

1. What is the UI (*)

The UI is the abbreviation for user Interface (UI). UI design refers to the whole design of human-computer interaction, Operation Logic, and beautiful interface of the soft parts. A good UI set- up is not only to make the software has a personality and taste, but also to make the operation of the software comfortable, simple, free, fully reflect the positioning and characteristics of the software.

2. First UI Engineering

1) where is the program entry for UI Engineering (*)

In the Appdelegate class (the proxy object of uiapplication);

2) What is uiapplicationmain (*)

Each program must have an instance of UIApplication (or its subclasses) at run time . Create a singleton instance of UIApplication. This can be done by calling [UIApplication Sharedapplication] to get a pointer to the singleton instance.

one of the main tasks of uiapplication is to handle user events, which creates a queue that puts all user events into the queue, processing them

at the time of processing, it sends the current event to an appropriate target control for handling the event . In addition, the UIApplication instance maintains a window list (UIWindow instance) opened in the app so that it can touch any of the UIView objects in the app. The UIApplication instance is given a proxy object to handle the application's lifecycle events (such as program startup and shutdown), system events (such as incoming calls, warning alerts), etc.

3) iOS program icon and program name settings (* *)

Modify the bundle name in the Info.plist configuration file

The image must be in PNG format, and the pixel dimensions must conform to the requirements

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

UIWindow

1.iPhone applications typically have only one window, represented as an instance of a UIWindow class . The application creates this window at startup and adds one or more views to the window and displays it.

The 2.UIWindow object is the root of all uiview, managing and coordinating the application's display . A generic application has only one UIWindow object, and even if there are multiple UIWindow objects, only one UIWindow can accept the user's touchscreen event.

Note: UIWindow inherits from UIView

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

UIView use

1.UIView Preliminary Introduction

All the visible classes in iOS are directly or indirectly inherited from UIView

2.UIView function

1) The view is an instance of the UIView class and is responsible for defining a rectangular area on the screen.

Views play a key role in presenting the user interface and in responding to user interface interactions.

Each view object is responsible for rendering the content in the view rectangle area and responding to the action events that occur in that area. Views are an important mechanism for applications to interact with users. In addition to displaying content and handling events, views can also be used to manage one or more child views.

2) A child view is a view object that is embedded inside the border of another view object, and the embedded view is called a parent view or a super view. This layout of the view is called the view layer , a view can contain any number of sub-views, and the view can be nested in any depth by adding a child view to the child views. The child view is always displayed above its parent view. Each parent view is responsible for managing its immediate child views, adjusting their location and dimensions as needed, and responding to events that they do not handle.

The 3.iPhone screen uses dots to calculate coordinates.

Model x y

iPhone4 * 480

iphone4s * 480

iPhone5 * 568

iphone5s * 568

iPhone6 375 * 667

iPhone6 Plus 414 * 736

Normal screen 1 dots = 1 pixels

Retina Screen 1 dots = 4 pixels

6 Plus 1 points = 9 pixels

coordinate system of 4.iPhone

1) The origin is in the upper left corner .

2) to the right of the positive direction of X, down to the square of y

5.UIView Common Properties and coordinate properties

1) coordinate system in iOS

2) Frame: The position and size of the view in the parent view coordinate system. (reference point is, Father's coordinate system)

3) Bounds: position and size of the view in its own coordinate system. (reference point is, own coordinate system)

4) Center: The location of the view's central point in the parent view coordinate system.

(reference point is, Father's coordinate system)

hierarchical relationship of 6.UIView

1) Add a sub-view: Addsubview

[Self.window Addsubview:label];

2) Remove from parent view: Removefromsuperview

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

UIlabel

1.UIFont Class Common methods

1) Create a Uifont object

(Uifont *) Fontwithname: (NSString *) name Size: (cgfloat) Size

Label.font = [Uifont fontwithname:@ "Zapfino" size:20];

2) Traverse System Font Library

(Nsarray *) Familynames

Get the font library for your system

Nsarray *fontarr = [Uifont familynames];

3) Set Bold

(Uifont *) Boldsystemfontofsize: (cgfloat) Size

Label.font = [Uifont boldsystemfontofsize:20];

2.UILabel How to change font color

1) Font color: SetTextColor

2) Text Shadow color: setShadowColor

3) Set Text shadow offset: Setshadowoffset

The shadow is offset by 20 units toward the square of the x in relation to its label, and 20 units in the Y direction.

Label.shadowoffset = Cgsizemake (a);

//Set shadow color

Label.shadowcolor = [Uicolor graycolor];

3.UILabel text alignment: Settextalignment

1) nstextalignmentleft-left alignment

2) Nstextalignmentcenter Center alignment

3) Right Align Nstextalignmentright

Label.textalignment = Nstextalignmentcenter;

4.UILabel Multi-line display: NumberOfLines

0 represents an infinite line break until the label itself is outside the range

label.numberoflines = 0;

5. Adaptive content, set Uilabel frame based on content size

//textsize the size of the area occupied by the last string content

cgsize textSize = [str boundingrectwithsize:cgsizemake (+) Options:nsstringdrawinguseslinefragmentorigin Attributes:dic context:nil].size;

//Create a Uilabel, the size of the uilabel varies according to the textsize

UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (0, Textsize.width, textsize.height)];

iOS Development-ui (i) Supplemental UIWindow UIView UIlabel

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.