---
title: "transformingAttributes(_:_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedstring/transformingattributes(_:_:)-9prm2"
---

# transformingAttributes(_:_:)

Returns an attributed string by calling a closure that transforms one attribute of a source attributed string.

## Declaration

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

## Parameters

- `k`: The doc://com.apple.foundation/documentation/Foundation/AttributedStringKey that identifies the attribute to transform.
- `c`: The closure that receives an doc://com.apple.foundation/documentation/Foundation/AttributedString/SingleAttributeTransformer that you use to access and alter the attribute’s range and value.

## Return Value

Return Value An attributed string with the applied transformation to the specified attribute.

## See Also

### Transforming Attributes

- [transformingAttributes(_:_:)](foundation/attributedstring/transformingattributes(_:_:)-64qnl.md)
- [transformingAttributes(_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:)-7kw1o.md)
- [transformingAttributes(_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:)-8gt2n.md)
- [transformingAttributes(_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:)-4owv7.md)
- [transformingAttributes(_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:)-5xmlf.md)
- [transformingAttributes(_:_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:_:)-9uodg.md)
- [transformingAttributes(_:_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:_:)-all0.md)
- [transformingAttributes(_:_:_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:_:_:)-3i7ac.md)
- [transformingAttributes(_:_:_:_:_:_:)](foundation/attributedstring/transformingattributes(_:_:_:_:_:_:)-9hppo.md)
- [AttributedString.SingleAttributeTransformer](foundation/attributedstring/singleattributetransformer.md)
