Adjusting Sizes
In the simplest usage patterns, a view’s frame and bounds control its size. A frame, as you’ve already seen, defines the location of a view in its parent’s coordinate system. If the frame’s origin is set to (0.0, 30.0), the view appears in the superview flush with the left side of the view and offset 30 points from the top. On non-Retina displays, this corresponds to 30 pixels down; on Retina displays, it is 60 pixels down.
Bounds define a view within its own coordinate system. Therefore, the origin for a view’s bounds (that is, myView.bounds
) is normally (0.0, 0.0). For most views, the size matches the normal extent—that is, the frame’s size
property. (This isn’t always true for some classes, like UIScrollView
, whose extent may ...
Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.