---
title: "init(attribute:relativeTo:attribute:scale:offset:)"
framework: quartzcore
role: symbol
role_heading: Initializer
path: "quartzcore/caconstraint/init(attribute:relativeto:attribute:scale:offset:)"
---

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

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

## Declaration

```swift
init(attribute attr: CAConstraintAttribute, relativeTo srcId: String, attribute srcAttr: CAConstraintAttribute, scale m: CGFloat, 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.
- `m`: The amount to scale the value of srcAttr.
- `c`: The offset added to the value of srcAttr.

## Return Value

Return Value An initialized constraint object using the specified parameters.

## Discussion

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

## See Also

### Create a New Constraint

- [init(attribute:relativeTo:attribute:offset:)](quartzcore/caconstraint/init(attribute:relativeto:attribute:offset:).md)
- [init(attribute:relativeTo:attribute:)](quartzcore/caconstraint/init(attribute:relativeto:attribute:).md)
