<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/AttributedString/transformingAttributes(_:_:_:)-7kw1o",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation16AttributedStringV22transformingAttributesyACxm_q_myAC26SingleAttributeTransformerVy_xGz_AFy_q_GztXEtAA0bC3KeyRzAaIR_r0_lF"
  },
  "title" : "transformingAttributes(_:_:_:)"
}
-->

# transformingAttributes(_:_:_:)

Returns an attributed string by calling a closure that transforms two attributes of a source attributed string.

```
@preconcurrency func transformingAttributes<K1, K2>(_ k: K1.Type, _ k2: K2.Type, _ c: (inout AttributedString.SingleAttributeTransformer<K1>, inout AttributedString.SingleAttributeTransformer<K2>) -> Void) -> AttributedString where K1 : AttributedStringKey, K2 : AttributedStringKey, K1.Value : Sendable, K2.Value : Sendable
```

## Parameters

`k`

The [`AttributedStringKey`](/documentation/Foundation/AttributedStringKey) that identifies an attribute to transform.

`k2`

The [`AttributedStringKey`](/documentation/Foundation/AttributedStringKey) that identifies a second attribute to transform.

`c`

A closure that receives two [`AttributedString.SingleAttributeTransformer`](/documentation/Foundation/AttributedString/SingleAttributeTransformer) instances that you use to access and alter the attributes’ ranges and values.

## Return Value

An attributed string with the applied transformations to the specified attributes.

---

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)