Child view Actual position = Parent View actual location-parent view bounds coordinates + child view frame coordinates
First, bounds
Affects only the position of the child view relative to the screen, and does not affect its relative screen position when modified
Bounds coordinates: Your own defined coordinate system, Setbound indicates the coordinates of the upper-left corner of this view in the coordinate system,
Default value (0,0)
Second, frame
The modification changed its position in the parent view coordinate system (bounds coordinate system), its own position and
The child view location will be changed.
Frame coordinates: The coordinates of the upper-left corner of the child view in the parent view coordinate system (bounds coordinate system), default value (0,0)
Third, the chart explanation
See the following code first you must understand something:
-(CGRect) frame{
return CGRectMake (self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
-(CGRect) bounds{
return CGRectMake (0,0,self.frame.size.width,self.frame.size.height);
}
It is clear that the origin of a view's bounds is always (0,0) (The coordinate system of the view itself, which is always 0, 0, unless it is considered setbounds), and the view's frame origin is arbitrary (relative to the coordinate position in the parent view).
Look at sketch and you'll see.
Frame: The position and size of the view in the parent view coordinate system. (reference point is, Father's coordinate system)
Bounds: The position and size of the view in the local coordinate (own) system. (The reference point is that the local coordinate system is equivalent to VIEWB's own coordinate system, starting at 0, 0 points)
Center: The position and size of the view's central point in the parent view coordinate system. (reference point is, Father's coordinate system)
Bounds This property is referenced by this local coordinate system. In fact, the key to the local coordinate system is to know where its origin (0,0) is. (This position is also relative to the upper view of the local coordinate system, of course, the top layer of view is Self.window.) Its local coordinate system origin is the upper left corner of the screen.
By modifying the view's Bounds property, you can modify the local coordinate system's origin location, which affects the coordinates of all the view's child view.
iOS view frame vs. bounds