<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSLayoutDimension/constraint(equalTo:multiplier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutDimension(im)constraintEqualToAnchor:multiplier:"
  },
  "title" : "constraint(equalTo:multiplier:)"
}
-->

# constraint(equalTo:multiplier:)

Returns a constraint that defines the anchor’s size attribute as equal to the specified anchor multiplied by the constant.

```
func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat) -> NSLayoutConstraint
```

## Parameters

`anchor`

A dimension anchor from a [`UIView`](/documentation/UIKit/UIView), <doc://com.apple.documentation/documentation/AppKit/NSView>, or [`UILayoutGuide`](/documentation/UIKit/UILayoutGuide) object.

`m`

The multiplier constant for the constraint.

## Return Value

An [`NSLayoutConstraint`](/documentation/UIKit/NSLayoutConstraint) object that defines the attribute represented by this layout anchor as equal to the attribute represented by the `anchor` parameter multiplied by the `m` constant.

## Discussion

This method defines the relationship `first attribute = m * second attribute`. Where `first attribute` is the layout attribute represented by the anchor receiving this method call, and `second attribute` is the layout attribute represented by the `anchor` parameter.

The constraints produced by the following two examples are identical.

```objc
// Creating a constraint using NSLayoutConstraint
[NSLayoutConstraint
 constraintWithItem:self.saveButton
 attribute:NSLayoutAttributeWidth
 relatedBy:NSLayoutRelationEqual
 toItem:self.cancelButton
 attribute:NSLayoutAttributeWidth
 multiplier:2.0
 constant:0.0].active = YES;
 
// Creating the same constraint using constraintEqualToAnchor:multiplier:
[self.saveButton.widthAnchor constraintEqualToAnchor:self.cancelButton.widthAnchor multiplier:2.0].active = YES;
```

---

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)