<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/transformAnchorPreference(key:value:transform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE25transformAnchorPreference3key5value0D0Qrqd_0_m_AA0E0V6SourceVyqd___Gy5ValueQyd_0_z_AIyqd__GtctAA0F3KeyRd_0_r0_lF"
  },
  "title" : "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.

```
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

a new version of the view that writes the preference.

---

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)