| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/QuartzCore.framework |
| Availability | Available in Mac OS X v10.5 and later. |
| Declared in | CAConstraintLayoutManager.h |
| Companion guides |
CAConstraint represents a single layout constraint between two layers. 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 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.
Important: It is possible to create constraints that result in circular references to the same attributes. In cases where the layout is unable to be computed the behavior is undefined.
+ constraintWithAttribute:relativeTo:attribute:scale:offset:
+ constraintWithAttribute:relativeTo:attribute:offset:
+ constraintWithAttribute:relativeTo:attribute:
– initWithAttribute:relativeTo:attribute:scale:offset:
Creates and returns an CAConstraint object with the specified parameters.
+ (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr
The attribute of the layer for which to create a new constraint.
The name of the layer that this constraint is calculated relative to.
The attribute of srcLayer the constraint is calculated relative to.
A new CAConstraint object with the specified parameters. The scale of the constraint is set to 1.0. The offset of the constraint is set to 0.0.
The value for the constraint is calculated is srcAttr.
CAConstraintLayoutManager.hCreates and returns an CAConstraint object with the specified parameters.
+ (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr offset:(CGFloat)offset
The attribute of the layer for which to create a new constraint.
The name of the layer that this constraint is calculated relative to.
The attribute of srcLayer the constraint is calculated relative to.
The offset added to the value of srcAttr.
A new CAConstraint object with the specified parameters. The scale of the constraint is set to 1.0.
The value for the constraint is calculated as (srcAttr + offset).
CAConstraintLayoutManager.hCreates and returns an CAConstraint object with the specified parameters.
+ (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr scale:(CGFloat)scale offset:(CGFloat)offset
The attribute of the layer for which to create a new constraint.
The name of the layer that this constraint is calculated relative to.
The attribute of srcLayer the constraint is calculated relative to.
The amount to scale the value of srcAttr.
The offset from the srcAttr.
A new CAConstraint object with the specified parameters.
The value for the constraint is calculated as (srcAttr * scale) + offset).
CAConstraintLayoutManager.hReturns an CAConstraint object with the specified parameters. Designated initializer.
- (id)initWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr scale:(CGFloat)scale offset:(CGFloat)offset
The attribute of the layer for which to create a new constraint.
The name of the layer that this constraint is calculated relative to.
The attribute of srcLayer the constraint is calculated relative to.
The amount to scale the value of srcAttr.
The offset added to the value of srcAttr.
An initialized constraint object using the specified parameters.
The value for the constraint is calculated as (srcAttr * scale) + offset).
CAConstraintLayoutManager.hThese constants represent the geometric edge or axis of a constraint.
enum _CAConstraintAttribute { kCAConstraintMinX, kCAConstraintMidX, kCAConstraintMaxX, kCAConstraintWidth, kCAConstraintMinY, kCAConstraintMidY, kCAConstraintMaxY, kCAConstraintHeight, };
kCAConstraintMinXThe left edge of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintMidXThe horizontal location of the center of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintMaxXThe right edge of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintWidthThe width of a layer.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintMinYThe bottom edge of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintMidYThe vertical location of the center of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintMaxYThe top edge of a layer’s frame.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
kCAConstraintHeightThe height of a layer.
Available in Mac OS X v10.5 and later.
Declared in CAConstraintLayoutManager.h.
CAConstraint.hThe constraint attribute type.
typedef int CAConstraintAttribute;
CAConstraintLayoutManager.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-24)