NSView's bounds vs frame

AWF4vk picture AWF4vk · Dec 13, 2011 · Viewed 24.6k times · Source

What's the difference between bounds and frame? In fact, why does 'bounds' even exist? The size of 'bounds' is equal to the frame's size, and the bound's origin should always be 0,0.

Answer

Dan picture Dan · Dec 13, 2011

From the View and Window Architecture Programming Guide for iOS:

A view object tracks its size and location using its frame, bounds, and center properties:

The frame property contains the frame rectangle, which specifies the size and location of the view in its superview’s coordinate system.

The bounds property contains the bounds rectangle, which specifies the size of the view (and its content origin) in the view’s own local coordinate system.

The center property contains the known center point of the view in the superview’s coordinate system.

Here is a good visualization of that explanation:

enter image description here