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}
?
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);
Bounds
bounds is inside of UIView means width and height.
(width,height);
Frames
frame is where it should be start relative to its superview and its bounds
(from x,from y ,width,height);
starting point from superview + its bound
精彩评论