Class

CAConstraint

CAConstraint represents a single layout constraint between two layers. Each CAConstraint instance encapsulates one geometry relationship between two layers on the same axis.

Overview

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 maximum 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.

Symbols

Create a New Constraint

init(attribute: CAConstraintAttribute, relativeTo: String, attribute: CAConstraintAttribute, offset: CGFloat)

Creates and returns an CAConstraint object with the specified parameters.

init(attribute: CAConstraintAttribute, relativeTo: String, attribute: CAConstraintAttribute)

Creates and returns an CAConstraint object with the specified parameters.

init(attribute: CAConstraintAttribute, relativeTo: String, attribute: CAConstraintAttribute, scale: CGFloat, offset: CGFloat)

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

Accessing Constraint Values

var attribute: CAConstraintAttribute

The attribute the constraint affects.

var offset: CGFloat

Offset value of the constraint attribute.

var scale: CGFloat

Scale factor of the constraint attribute.

var sourceAttribute: CAConstraintAttribute

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

var sourceName: String

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

Constants

CAConstraintAttribute

The constraint attribute type.

Relationships

Inherits From