Objective-c – NSView’s bounds vs frame

cocoansviewobjective c

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.

Best Answer

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

Related Topic