Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the bounds of an UIView a CGRect and not a CGSize?

Is there a reason why the bounds property of UIView (an NSView) are a CGRect when the only information you'll ever want in that property are the size of that CGRect.

Is it just a shortcut for drawing since you'll need a CGRect when drawing? Or just a very specific special case where the origin of the bounds could be something else than {0, 0}?

like image 840
gcamp Avatar asked Jul 02 '11 16:07

gcamp


1 Answers

The frame specifies where the view is relative to the superview, while bounds specifies where the view is allowed to draw relative to the frame.

By changing the bounds origin and/or width you can get clipping, e.g., or drawing outside of the view.

I.e, bounds origin is normally (0,0) but it must not be always so, like when you do clipping.

Furthermore, bounds is used by affine transformations instead of the frame and it represents the position after transformation which could also have an origin different from (0,0);

like image 74
sergio Avatar answered Nov 02 '22 19:11

sergio