Managing Constraints
All constraints belong to the NSLayoutConstraint
class, regardless of how they are created. When working with constraints, you can add them to your views either one by one, using addConstraint:
, or in arrays by using the addConstraints:
instance method (notice the s at the end of the name). In day-to-day work, you often deal with collections of constraints that are stored in arrays.
A constraint always has a natural home in the nearest common ancestor of the views involved in the constraint. A constraint must be installed on a common ancestor of every view referenced. A self-installing category method on NSLayoutConstraint
can programmatically determine the natural and correct view for installation. This is left as an exercise ...
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.