Details on common properties of UIView and details of uiview
The previous section describes some common attributes of a space. This section describes the common attributes of a UIVIew.
First, introduce the common attributes of the UIView described in the previous article:
// Position and size of the rectangle of the control in the parent control (with the coordinate origin in the upper left corner of the parent Control) @ property (nonatomic) CGRect frame; // The position and size of the rectangle where the control is located (the coordinate origin is in the upper left corner of the control, so the x \ y of bounds is usually 0) @ property (nonatomic) CGRect bounds; // The position of the control's midpoint (with the upper left corner of the parent control as the coordinate origin) @ property (nonatomic) CGPoint center; // control deformation attributes (you can set attributes such as rotation angle, proportional scaling, and translation) @ property (nonatomic) CGAffineTransform transform;
To learn about these common attributes, you must first know that in UIKit, the origin () of the coordinate system is in the upper left corner, the x value is in the forward direction to the right, and the y value is in the forward direction, as shown in
@ Property (nonatomic) CGRect frame;
struct CGRect { CGPoint origin; CGSize size;};typedef struct CGRect CGRect;
CGRect is a struct with the origin and size attributes. The origin is a CGPoint and a vertex. It has two attributes X/Y, representing the position.
Size is a CGSize, which has two attributes: Width/Height, representing the Width and Height.
The frame attribute describes the position and size of the current view in the parent view.
Therefore, the reference point of the frame attribute of the button is the parent view (newly added view), with the coordinate origin in the upper left corner of the parent view.
@ Property (nonatomic) CGRect bounds;
The main difference between the frame and the position and size of the rectangle frame where the control is located (the coordinate origin is in the upper left corner of the control, so the x \ y of bounds is generally 0) is also true.
@ Property (nonatomic) CGPoint center;
Control Point Position (with the upper left corner of the parent control as the coordinate origin): A CGPoint with only the x/y attribute.
@ Property (nonatomic) CGAffineTransform transform;
Control deformation attributes (you can set attributes such as rotation angle, proportional scaling, and translation)
Summary:
You can use frame \ center \ transform to modify the widget's position.
You can use frame \ bounds \ transform to modify the widget size.