Lan Yi Education Record

Source: Internet
Author: User
Tags home screen

Create an empty project first

Currently there are no empty items created that can only create a separate view of the project delete Viewcontroller and Main.storyboard, and then in APPDELEGATE.M-(BOOL) Application: (Uiappllication * ) applic didfinishlaunchingwithoption: (Nsdictionary *) launchoptions{} Add a window(at least one WINDOWC window per project)




Static page (control position Fixed) using SB(Storyboard)

Dynamic pages are used without SB.


1. Create the Code for window:

1) Code Add window

Self.window =[uiwindow alloc]initwithframe:[UIScreen mainscreen].bounds; (UIScreen is the screen, Mainscreen home screen Bounds is the full size of the view that is added, if the content using Frame:cgrectmake () is relative to the position coordinates in the added view)

Self.window.backgroundcolor=[uicolor Whitecolor];

[Self.window makekeyandvisible]; (Take this window as the main window and show it)

2) You also need to delete the value of main interface in the second-largest class of depleyment info in the root directory of the number of items.

2. Displaying the page in window requires first creating a Viewcontroller

2. Create Viewcontroller

1. Create only one Viewcontroller page nothing is added (Empty page is useless)

Uiviewcontroller *vc=[[uiviewcontroller Alloc]init]; (Create a page called VC)

Self.window.rootViewController =VC; (make VC the Root View Control page of control window)

2. Create a page that can write Viewcontroller

1) First create a class that inherits Uiviewcontroller

2) First introduce this page when creating Viewcontroller

3) Then create the page with the new Viewcontroller class

Myviewcontroller *vc=[myviewcontroller Alloc]init];

Self.window.rootViewController =VC

4) You can add a related action to the new Viewcontroller

Hierarchical relationship of pages:

From outside to Inside: screen-window-uiviewcontroller-view/controls



3. Create a UIView view

1, UIView quite a container to carry a certain control and then set to a transparent background, you can control the UIView to control these controls at the same time.

Control UIView is equivalent to controlling the whole of the controls on which these are hosted.

2, UIView of common methods:

1) Superview (parent view) to a control's dress chart

Above L.superview is V,

V,superview is Self.view,

Self.view.superview is window.

2) Child view

Nsarray *subviews=self.view.subviews; (Create an array subviews to get all the sub-views mounted above) (if the page has an automatic layout, the Self.view child view will be more than two see the word view


NSLog (@ "%@", subviews); display array

3) Add sub-view addsubview;

[a addsubview b]; (add B view to a view)

4) Insert View Insertsubview: Insert master and apprentice into specified position

[a insertsubview:b atindex:i]; (add B to the I position in view a)

[a insertsubview:b abovesubview:c]; (add view B to view A to eat above )

[a insertsubview:b belowsubview:c]; (add view B to view a to eat below)

5) Move the handle view to the front (top) Bringsubviewtofront:

[Self.view bringsubviewtofront:a]; (move view A to the front of the Self.view)

6) Swap View location

[Self.view exchangesubviewatindex:0 Withsubviewatindex:3]; (Swap views in the Self.view view at 0 and at 3 locations)

7) Delete View Removesubview

[A removesubview:b]; (remove B view from view a)


3. UIView properties of the View (all controls have properties because all controls inherit from UIView)

1) Transparency Alpha

A.alpha = 0.5; (Modify the transparency of control A, 0-1,0 is completely transparent, 1 is opaque)

2) Hide Control hidden

A.hidden =yes; (Hide control a)

3) Background background


Lan Yi Education Record

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.