A comparison between frame and bounds

Source: Internet
Author: User

The bounds in the translation document refers to the coordinates and size of this view in its own coordinate system, and frame refers to the coordinates and size of this view in its Superview coordinate system. The difference is mainly in the coordinate system. It is obvious that one is the coordinate system of the origin, and one is the coordinate system with the screen as the Origin point. Absolute coordinates ... Relative coordinates ... For example, when the screen is rotated, it should be redrawn in relative order. Frame if a button is in the table, the coordinates of the button frame are relative, not relative to the screen, that is, relative coordinates, not absolute coordinates?? I also want to know how any one uiview to get its coordinates on the screen. The frame of view is the position and size of view in its Super view. The bounds of view can be used to help its subview to locate, layoutsubviews. Frame is in terms of Superview ' s coordinate system?? The frame is the coordinate system from the parent view??? Bounds is in terms of local coordinate system?

Frame and bounds are the two properties in the UIView.

Frame refers to the position and size of the view in the parent view coordinate system. (The reference point is the father's coordinate system)

Bounds refers to the position and size of the view in its own coordinate system. (The reference point is its own coordinate system)

-(CGRect) frame{

Returncgrectmake (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);

}

Obviously, the origin of the bounds is the (0,0) point, and the frame's origin is arbitrary. Frame if a button is in the table, the coordinates of the button frame are relative, not relative to the screen, that is, relative coordinates, not absolute coordinates. Frame is the relative coordinate. Bounds is the absolute coordinate. ? In the Android development process, absolute coordinates, so that the position is drawn relative to the screen and not relative to the control?? what is the absolute coordinate value, the relative coordinate value?   the absolute coordinates are: x, Y is relative to the origin of the coordinates.? for example (15,20) relative coordinates are: @x,y is relative to the reference point (can be a point of their own set). For example (15,20) coordinates relative to the reference point ("X"), indicating: @14,19 (15,20) is relative to the reference point ( -1,-1), which means: @16,21?bounds refers to the coordinates and size of this view in its own coordinate system Frame refers to the coordinates and size of the view in its Superview coordinate system. The difference is mainly in the coordinate system of this piece.? It is obvious that one is the coordinate system of the origin, and one is the coordinate system with the screen as the Origin point.

A comparison between frame and bounds

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.