Well although it’s late in the dark night, I don’t get why there are two different rectangles: frame and bounds.
Like I understand it, one single rectangle would have been just enough to do everything. Positioning the View itself relative to another coordinate system, and then clipping its contents to a specified size. What else would you do with two rectangles? And how do they interact with each other?
Does anyone have a good explanation? The one from the Apple docs with the kid holding the fruit is not very good for understanding.
Here’s the cheatsheet:
frameis where the view is (with respect to the superview)boundsis where the view is allowed to draw (with respect to itself)Some more clarification:
If you are positioning the view in its superview, you almost always change the frame origin.
If you are clipping where the UIView is drawing, you almost always modify its bounds.
Note that you are allowed to have bounds that is bigger than the frame. That is, you can draw “outside the lines” of where you are.