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