---
title: "constraints(withVisualFormat:options:metrics:views:)"
framework: appkit
role: symbol
role_heading: Type Method
path: "appkit/nslayoutconstraint/constraints(withvisualformat:options:metrics:views:)"
---

# constraints(withVisualFormat:options:metrics:views:)

Creates constraints described by an ASCII art-like visual format string.

## Declaration

```swift
class func constraints(withVisualFormat format: String, options opts: NSLayoutConstraint.FormatOptions = [], metrics: [String : Any]?, views: [String : Any]) -> [NSLayoutConstraint]
```

## Parameters

- `format`: The format specification for the constraints.
- `opts`: Options describing the attribute and the direction of layout for all objects in the visual format string.
- `metrics`: A dictionary of constants that appear in the visual format string. The dictionary’s keys must be the string values used in the visual format string. Their values must be doc://com.apple.documentation/documentation/Foundation/NSNumber objects.
- `views`: A dictionary of views that appear in the visual format string. The keys must be the string values used in the visual format string, and the values must be the view objects.

## Return Value

Return Value An array of constraints that, combined, express the constraints between the provided views and their parent view as described by the visual format string. The constraints are returned in the same order they were specified in the visual format string.

## Discussion

Discussion For more information, see NSLayoutConstraint.

## See Also

### Related Documentation

- [NSLayoutConstraint](appkit/nslayoutconstraint.md)

### Creating constraints

- [init(item:attribute:relatedBy:toItem:attribute:multiplier:constant:)](appkit/nslayoutconstraint/init(item:attribute:relatedby:toitem:attribute:multiplier:constant:).md)
