An object that provides a constraint-based layout manager.
- macOS 10.5+
You use the shared instance of this object by assigning it to the
layout property of any layer objects to which you have added constraints. During a layout update, Core Animation uses the layout manager to update the size and position of the sublayers based on the registered set of constraints.
Constraints let you define a set of geometric relationships between a layer and its sibling layers or between a layer and its superlayer. These relationships are expressed using constraint objects, which are instances of the
CAConstraint class. When creating constraints, you can reference a layer by name using that object’s
name property. You can also use the special name
superlayer to refer to the layer's superlayer.
Listing 1 shows how you can use
CAConstraint to create a layer containing two constrained sublayers:
right. A series of
CAConstraint objects are created so that the sublayers match their superlayer's height and are half of its width.
left matches the
min attribute and
right matches the
The end result is that the two sublayers are always laid out so that
left fills the left half of
right fills the right half of layer.
This class is not meant to be subclassed.