Sobes.tech
Junior — Middle

Are there any differences between the properties Frame and Bounds of a graphical element?

sobes.tech AI

Answer from AI

In iOS, graphical elements (UIView) have properties frame and bounds that describe different things:

  • frame — is a rectangle that describes the position and size of the element in the coordinate system of its superview (parent view). That is, frame.origin is the position relative to the parent.

  • bounds — is a rectangle that describes the internal coordinate system of the element itself. Usually, bounds.origin is (0,0), and the size matches the size of the element.

Example:

If you move the element, its frame.origin changes. If you change bounds, for example, shifting its origin, the content inside the element will move within it, but the element itself will stay in place.

Thus, frame is responsible for position and size in the parent coordinate system, and bounds for the internal coordinate system of the element.

Are there any differences between the properties… - sobes.tech