IOS development-UI (1) supplement UIWindow UIView UIlabel,-uiuiwindow

Source: Internet
Author: User

IOS development-UI (1) supplement UIWindow UIView UIlabel,-uiuiwindow

I forgot to sort it out before. Now I want to add that I should put it in front

Knowledge point:

1. Preliminary understanding of UI

2. UIWindow

3. UIView

4. UIlabel

 

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

Preliminary understanding of UI

 

1. What is UI (*)

The UI is short for the User Interface. Uidesign refers to the overall design of man-machine interaction, operation logic, and beautiful interface of software. A good UI design not only makes the software personal and tasteful, but also makes the software operation comfortable, simple, free, and fully reflects the positioning and characteristics of the software.

 

2. The first UI Project

 

1) Where is the UI project program entry (*)

In the AppDelegate class (the proxy object of the UIApplication );

 

2) What is UIApplicationMain (*)

Each program must have only one UIApplication (or its subclass) instance at runtime. Create a single instance of UIApplication. In this way, you can call [UIApplication sharedApplication] to obtain the pointer of this Singleton instance.

 

A major task of UIApplication is to process user events. It creates a queue, puts all user events in the queue, and processes them one by one,

During processing, it sends the current event to a metric control suitable for processing the event. In addition, the UIApplication instance maintains a window list (UIWindow instance) opened in this application so that it can access any UIView object in the application. The UIApplication instance is assigned a proxy object to process application lifecycle events (such as program startup and shutdown), system events (such as incoming calls and alarm items), and so on.

 

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 size must meet the requirements.

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

UIWindow

 

1. iPhone applications usually have only one window, which indicates an instance of the UIWindow class. The application creates this window at startup, adds one or more views to the window, and displays them.

 

2. The UIWindow object is the root of all uiviews. It manages and coordinates the display of applications. Generally, an application only has one UIWindow object. Even if multiple UIWindow objects exist, only one UIWindow can receive user touch screen events.

 

Note: UIWindow inherits from UIView

 

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

UIView usage

 

1. UIView Overview

In ios, all visible and tangible classes are directly or indirectly inherited from UIView.

 

2. Functions of UIView

1) A view is an instance of the UIView class and defines a rectangular area on the screen.

Views play a key role in displaying user interfaces and responding to user interface interactions.

Each view object is responsible for rendering the content in the rectangular area of the view and responding to Operation events in the area. View is an important mechanism for interaction between applications and users. In addition to displaying content and processing events, views can also be used to manage one or more child views.

 

2) A subview is a view object embedded in the border of another view object. An embedded view is called a parent view or a superview. This layout method of a view is called a view layer. A view can contain any number of subviews. By adding subviews to a subview, the view can be nested in any depth. A child view is always displayed above its parent view. Each parent view is responsible for managing its direct child views, adjusting their positions and sizes as needed, and responding to events they have not processed.

 

3. The iPhone screen uses vertices to calculate coordinates.

Model x y

IPhone 4 320*480

IPhone4S 320*480

IPhone5 320*568

IPhone5S 320*568

IPhone6 375*667

IPhone6 Plus 414*736

 

Normal Screen 1 point = 1 pixel

Retina screen 1 point = 4 pixels

6 Plus 1 point = 9 pixels

 

4. iPhone Coordinate System

1) the origin is in the upper left corner.

2) To the right is the positive direction of x, down is the positive direction of y

 

 

5. UIView common attributes and coordinate attributes

1) Coordinate System in IOS

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

3) bounds: position and size of the view in its own coordinate system. (The reference point is your own coordinate system)

4) center: the center of the view is located in the coordinate system of the parent view.

(The reference point is the father's coordinate system)

 

6. hierarchical relationships of UIView

1) Add a subview: addSubView

[Self. window addSubview: label];

2) remove from parent view: removeFromSuperview

 

 

 

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

UIlabel

 

1. Common UIFont Methods

1) create a UIFont object

(UIFont *) fontWithName :( NSString *) name size :( CGFloat) size

Label. font = [UIFont fontWithName: @ "Zapfino" size: 20];

2) traverse the system library

(NSArray *) familyNames

// Obtain the system library

NSArray * fontArr = [UIFont familyNames];

3) set bold

(UIFont *) boldSystemFontOfSize :( CGFloat) size

Label. font = [UIFont boldSystemFontOfSize: 20];

 

2. How does UILabel change the font color?

1) font color: setTextColor

2) text shadowcolor: setShadowColor

3) set the text shadow offset: setShadowOffset

// The Shadow offsets 20 units from its label to the positive direction of X and 20 units from the Y direction.

Label. shadowOffset = CGSizeMake (20, 20 );

// Set the shadow color

Label. shadowColor = [UIColor grayColor];

3. UILabel text alignment: setTextAlignment

1) NSTextAlignmentLeft-> left alignment

2) NSTextAlignmentCenter-> center alignment

3) NSTextAlignmentRight-> right alignment

Label. textAlignment = NSTextAlignmentCenter;

4. UILabel multi-line display: numberOfLines

// 0 indicates unlimited line feed until it exceeds the label range.

Label. numberOfLines = 0;

5. Set the frame of UILabel Based on the Content size.

// TextSize indicates the area occupied by the last string content

CGSize textSize = [str boundingRectWithSize: CGSizeMake (200,300 0) 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, 20, textSize. width, textSize. height)];

 

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.