iOS ) Frame VS Bounds

Chan
2 min readMar 11, 2022

--

Frame is the frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

Bounds is the bounds rectangle, which describes the view’s location and size in its own coordinate system.

The key word for Frame is Superview’s coordinate system and for Bounds is its own coordinate system.

When to use frame and when to use bounds

Since frame relates a view's location in its parent view, you use it when you are making outward changes, like changing its width or finding the distance between the view and the top of its parent view.

Use the bounds when you are making inward changes, like drawing things or arranging subviews within the view. Also use the bounds to get the size of the view if you have done some transfomation on it.

from https://stackoverflow.com/questions/1210047/cocoa-whats-the-difference-between-the-frame-and-the-bounds

Practice

You can practice yourself by pushing buttons to change each component’s values. I hope this would help you to understand the difference explicitly. You can download this from https://github.com/ecc414/FrameVSBounds

Please let me know if there is any wrong information or mistake.

--

--