IOS10 the geometry of the UI tutorial view

Source: Internet
Author: User

IOS10 the geometry of the UI tutorial view

A subset of properties in the View property allows the defined view to be drawn on the screen. Before explaining these properties, we'll start by explaining the types of structures involved in defining the geometry of the view. These structure types are as follows:

    • Cgpoint: It represents a point in a two-dimensional coordinate system defined by the X and y two properties.
    • Cgsize: It represents the size of a rectangle, defined by width and height of two.
    • CGRect: It represents the position and size of a rectangle, defined by the origin and size two properties.

Note: The code required to initialize these struct types is very simple, and many features are provided by Apple, and using these types of structures can simplify the work of the developer.

Example 1-3:viewgeometry creates a blank view, where instances of CGRect, cgsize, and Cgpoint are used. The code is as follows:

Import Uikitclass Viewcontroller:uiviewcontroller {    override func Viewdidload () {        super.viewdidload ()        // Additional setup after loading the view, typically from a nib.        Let Point=cgpoint (x:67.0, y:217.0)                                                  //Instantiate a Cgpoint object let        size=cgsize (width:240.0, height:128.0)                                 // Instantiate a Cgsize object let        rect=cgrect (Origin:point, size:size)                                       //Instantiate a CGRect object let        newview=uiview (frame:rect)        Self.view.addSubview (newview)        newview.backgroundcolor=uicolor.red    } ...}

  

When you run the program, you see the effect shown in 1.8.

Figure 1.8 Running Effect

IOS10 the geometry of the UI tutorial view

related reading:iOS10 UI Tutorial Disabling view interaction with users

IOS10 the geometry of the UI tutorial view

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.