Starting Within View Bounds
The first method in Recipe 5-2, constrainWithinSuperviewBounds, requests that a view be placed entirely within its superview’s bounds. It creates four constraints to ensure this. One requires that the view’s left side be at or to the right of the superview’s left side, another that the view’s top be at or below the superview’s top, and so forth.
The reason for creating this method is that in a loosely constrained system, it’s entirely possible that your views will disappear offscreen with negative origins. This method basically says, “Please respect the (0,0) origin and the size of the superview when placing my subviews.”
In most real-world development, this set of constraints is not normally necessary. Such constraints ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access