Frame,bounds,center,position,anchorpoint Summary
The position property of a layer is a Cgpoint value that specifies the position of the layer as its parent layer, based on the parent layer's coordinate system.
The bounds property of a layer is a CGRect value that specifies the layer's size (bounds.size) and the layer's origin (bounds.origin). When you rewrite a layer's redraw method, the origin of the bounds can be used as the origin of the graphics context.
The layer has an implicit frame, which is part of the Position,bounds,anchorpoint and transform properties. Setting a new frame will change the layer's position and bounds properties accordingly, but the frame itself is not saved. But when the new frame is set, the origin of the bounds is undisturbed, and the size of the bounds becomes the size of the frame, which is bounds.size=frame.size.
The position of the layer is set to the appropriate position relative to the anchor Point (anchor points) . When you set the value of a frame, it is calculated in relation to the properties of position, bounds, and Anchorpoint.
When you set the frame property of a layer, the position will change according to the anchor (Anchorpoint), and when you set the Position property of the layer, bounds will change according to the anchor Point (anchorpoint) accordingly.
Frame,center and Bounds Properties
1.frame, center, and bounds properties
- Frame: Controlling Position and size
- Center: Control Position (center point)
- Bounds: Control size (in its own upper left corner as the origin)
2. Attention points
(1) The position of the control can be modified by the following properties
(2) The size of the control can be modified by the following properties
Position,anchorpoint
- Position: is a place where we need to set the control to use
For example: btn.position = cgpointmake (0, 0); the position of our corresponding control is (0,0)
But you think there are countless points in the control, how do you know that point as the point we're going to set, of course, we're all the center of the norm, but it's not the only one, so there's anchorpoint.
- Anchorpoint: Think that the point above the control is the corresponding point I want to set
Sometimes we will combine the above several properties to use, but according to the requirements of anchorpoint is generally used to implement not around the center point rotation function, two if we do not modify Anchorpoint, position default is the midpoint (parent control)
iOS development--using OC Chapter &frame,bounds,center,position,anchorpoint Summary