---
title: "mergingAttributes(_:mergePolicy:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedstringprotocol/mergingattributes(_:mergepolicy:)"
---

# mergingAttributes(_:mergePolicy:)

Returns an attributed string by merging the attributed string’s attributes with those in a specified attribute container.

## Declaration

```swift
func mergingAttributes(_ attributes: AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy = .keepNew) -> AttributedString
```

## Parameters

- `attributes`: The attribute container with the attributes to merge.
- `mergePolicy`: A policy to use when resolving conflicts between this string’s attributes and those in attributes.

## Return Value

Return Value An attributed string from merging the attributed string’s attributes with those in a specified attribute container. In cases where the same attribute exists in both the source string and attributes, the mergePolicy determines which value the returned string uses.

## See Also

### Applying Attributes

- [settingAttributes(_:)](foundation/attributedstringprotocol/settingattributes(_:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)
- [replacingAttributes(_:with:)](foundation/attributedstringprotocol/replacingattributes(_:with:).md)
