<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CAConstraint/init(attribute:relativeTo:attribute:offset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CAConstraint(cm)constraintWithAttribute:relativeTo:attribute:offset:"
  },
  "title" : "init(attribute:relativeTo:attribute:offset:)"
}
-->

# init(attribute:relativeTo:attribute:offset:)

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

```
convenience init(attribute attr: CAConstraintAttribute, relativeTo srcId: String, attribute srcAttr: CAConstraintAttribute, offset c: CGFloat)
```

## Parameters

`attr`

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

`srcId`

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

`srcAttr`

The attribute of `srcLayer` the constraint is calculated relative to.

`c`

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`).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)