Mac Developer Library

Developer

QuartzCore Framework Reference CAConstraint Class Reference

Options
Deployment Target:

On This Page
Language:

CAConstraint

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

Inheritance


Conforms To


Import Statement


import QuartzCore @import QuartzCore;

Availability


Available in OS X v10.5 and later.
  • Creates and returns an CAConstraint object with the specified parameters.

    Declaration

    Swift

    class func constraintWithAttribute(_ attr: CAConstraintAttribute, relativeTo srcLayer: String!, attribute srcAttr: CAConstraintAttribute, scale scale: CGFloat, offset offset: CGFloat) -> AnyObject!

    Objective-C

    + (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr scale:(CGFloat)scale offset:(CGFloat)offset

    Parameters

    attr

    The attribute of the layer for which to create a new constraint.

    srcLayer

    The name of the layer that this constraint is calculated relative to.

    srcAttr

    The attribute of srcLayer the constraint is calculated relative to.

    scale

    The amount to scale the value of srcAttr.

    offset

    The offset from the srcAttr.

    Return Value

    A new CAConstraint object with the specified parameters.

    Discussion

    The value for the constraint is calculated as ((srcAttr * scale) + offset).

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Creates and returns an CAConstraint object with the specified parameters.

    Declaration

    Swift

    class func constraintWithAttribute(_ attr: CAConstraintAttribute, relativeTo srcLayer: String!, attribute srcAttr: CAConstraintAttribute, offset offset: CGFloat) -> AnyObject!

    Objective-C

    + (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr offset:(CGFloat)offset

    Parameters

    attr

    The attribute of the layer for which to create a new constraint.

    srcLayer

    The name of the layer that this constraint is calculated relative to.

    srcAttr

    The attribute of srcLayer the constraint is calculated relative to.

    offset

    The offset added to the value of srcAttr.

    Return Value

    A new CAConstraint object with the specified parameters. The scale of the constraint is set to 1.0.

    Discussion

    The value for the constraint is calculated as (srcAttr + offset).

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Creates and returns an CAConstraint object with the specified parameters.

    Declaration

    Swift

    class func constraintWithAttribute(_ attr: CAConstraintAttribute, relativeTo srcLayer: String!, attribute srcAttr: CAConstraintAttribute) -> AnyObject!

    Objective-C

    + (id)constraintWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr

    Parameters

    attr

    The attribute of the layer for which to create a new constraint.

    srcLayer

    The name of the layer that this constraint is calculated relative to.

    srcAttr

    The attribute of srcLayer the constraint is calculated relative to.

    Return Value

    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.

    Discussion

    The value for the constraint is calculated is srcAttr.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    init!(attribute attr: CAConstraintAttribute, relativeTo srcLayer: String!, attribute srcAttr: CAConstraintAttribute, scale scale: CGFloat, offset offset: CGFloat)

    Objective-C

    - (id)initWithAttribute:(CAConstraintAttribute)attr relativeTo:(NSString *)srcLayer attribute:(CAConstraintAttribute)srcAttr scale:(CGFloat)scale offset:(CGFloat)offset

    Parameters

    attr

    The attribute of the layer for which to create a new constraint.

    srcLayer

    The name of the layer that this constraint is calculated relative to.

    srcAttr

    The attribute of srcLayer the constraint is calculated relative to.

    scale

    The amount to scale the value of srcAttr.

    offset

    The offset added to the value of srcAttr.

    Return Value

    An initialized constraint object using the specified parameters.

    Discussion

    The value for the constraint is calculated as (srcAttr * scale) + offset).

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • attribute attribute Property

    The attribute the constraint affects. (read-only)

    Declaration

    Swift

    var attribute: CAConstraintAttribute { get }

    Objective-C

    @property(readonly) CAConstraintAttribute attribute

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.6 and later.

  • offset offset Property

    Offset value of the constraint attribute. (read-only)

    Declaration

    Swift

    var offset: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat offset

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.6 and later.

  • scale scale Property

    Scale factor of the constraint attribute. (read-only)

    Declaration

    Swift

    var scale: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat scale

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.6 and later.

  • The constraint attribute of the layer the receiver is calculated relative to (read-only)

    Declaration

    Swift

    var sourceAttribute: CAConstraintAttribute { get }

    Objective-C

    @property(readonly) CAConstraintAttribute sourceAttribute

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.6 and later.

  • Name of the layer that the constraint is calculated relative to. (read-only)

    Declaration

    Swift

    var sourceName: String! { get }

    Objective-C

    @property(readonly) NSString *sourceName

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.6 and later.

Data Types

  • The constraint attribute type.

    Declaration

    Swift

    enum CAConstraintAttribute : Int32 { case MinX case MidX case MaxX case Width case MinY case MidY case MaxY case Height }

    Objective-C

    typedef int CAConstraintAttribute;

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Objective-C

    enum _CAConstraintAttribute { kCAConstraintMinX, kCAConstraintMidX, kCAConstraintMaxX, kCAConstraintWidth, kCAConstraintMinY, kCAConstraintMidY, kCAConstraintMaxY, kCAConstraintHeight, };

    Constants

    • MinX

      kCAConstraintMinX

      The left edge of a layer’s frame.

      Available in OS X v10.5 and later.

    • MidX

      kCAConstraintMidX

      The horizontal location of the center of a layer’s frame.

      Available in OS X v10.5 and later.

    • MaxX

      kCAConstraintMaxX

      The right edge of a layer’s frame.

      Available in OS X v10.5 and later.

    • Width

      kCAConstraintWidth

      The width of a layer.

      Available in OS X v10.5 and later.

    • MinY

      kCAConstraintMinY

      The bottom edge of a layer’s frame.

      Available in OS X v10.5 and later.

    • MidY

      kCAConstraintMidY

      The vertical location of the center of a layer’s frame.

      Available in OS X v10.5 and later.

    • MaxY

      kCAConstraintMaxY

      The top edge of a layer’s frame.

      Available in OS X v10.5 and later.

    • Height

      kCAConstraintHeight

      The height of a layer.

      Available in OS X v10.5 and later.

    Import Statement