Constraint Processing

The display of a view’s content proceeds through multiple phases. Prior to Auto Layout, two phases were provided: the layout phase and the rendering phase. Auto Layout augments the traditional two phases by inserting a third phase to kick off the process—the constraint phase.

The layout phase allows a developer to modify the frame geometry of the view’s subviews by implementing the layoutSubviews method. When iOS determines the view’s layout to be invalid, this method will be called, and you can update the manual layout of your subviews. You can also request a relayout by calling setNeedsLayout or layoutIfNeeded. The first method is a polite request that allows iOS to coalesce multiple layout requests and call layoutSubviews ...

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.