---
title: "transformAnchorPreference(key:value:transform:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/transformanchorpreference(key:value:transform:)"
---

# transformAnchorPreference(key:value:transform:)

Sets a value for the specified preference key, the value is a function of the key’s current value and a geometry value tied to the current coordinate space, allowing readers of the value to convert the geometry to their local coordinates.

## Declaration

```swift
nonisolated func transformAnchorPreference<A, K>(key _: K.Type = K.self, value: Anchor<A>.Source, transform: @escaping (inout K.Value, Anchor<A>) -> Void) -> some View where K : PreferenceKey

```

## Parameters

- `key`: The preference key type.
- `value`: The geometry value in the current coordinate space.
- `transform`: The function to produce the preference value.

## Return Value

Return Value A new version of the view that writes the preference.

## See Also

### Setting preferences based on geometry

- [anchorPreference(key:value:transform:)](swiftui/view/anchorpreference(key:value:transform:).md)
