Class

CAConstraint

A representation of a single layout constraint between two layers.

Declaration

@interface CAConstraint : NSObject

Overview

Each CAConstraint instance encapsulates one geometry relationship between two layers on the same axis.

Sibling layers are referenced by name, using the name property of each layer. The special name superlayer is used to refer to the layer's superlayer.

For example, to specify that a layer should be horizontally centered in its superview you would use the following:

theConstraint=[CAConstraint constraintWithAttribute:kCAConstraintMidX
                                         relativeTo:@"superlayer"
                                         attribute:kCAConstraintMidX];

A minimum of two relationships must be specified per axis. If you specify constraints for the left and right edges of a layer, the width will vary. If you specify constraints for the left edge and the width, the right edge of the layer will move relative to the superlayer’s frame. Often you’ll specify only a single edge constraint, the layer’s size in the same axis will be used as the second relationship.

Topics

Create a New Constraint

+ constraintWithAttribute:relativeTo:attribute:scale:offset:

Creates and returns an CAConstraint object with the specified parameters.

+ constraintWithAttribute:relativeTo:attribute:offset:

Creates and returns an CAConstraint object with the specified parameters.

+ constraintWithAttribute:relativeTo:attribute:

Creates and returns an CAConstraint object with the specified parameters.

- initWithAttribute:relativeTo:attribute:scale:offset:

Returns an CAConstraint object with the specified parameters. Designated initializer.

Accessing Constraint Values

attribute

The attribute the constraint affects.

offset

Offset value of the constraint attribute.

scale

Scale factor of the constraint attribute.

sourceAttribute

The constraint attribute of the layer the receiver is calculated relative to

sourceName

Name of the layer that the constraint is calculated relative to.

Constants

CAConstraintAttribute

These constants represent the geometric edge or axis of a constraint.

CAConstraintAttribute

The constraint attribute type.

Relationships

Inherits From

Conforms To

See Also

Layer Basics

CALayer

An object that manages image-based content and allows you to perform animations on that content.

CALayerDelegate

Methods your app can implement to respond to layer-related events.

CALayoutManager

Methods that allow an object to manage the layout of a layer and its sublayers.

CAConstraintLayoutManager

An object that provides a constraint-based layout manager.

CAAction

An interface that allows objects to respond to actions triggered by a CALayer change.