<!--
{
  "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/backgroundPreferenceValue(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE25backgroundPreferenceValueyQrqd__m_qd_0_0F0Qyd__ctAA0E3KeyRd__AaBRd_0_r0_lF"
  },
  "title" : "backgroundPreferenceValue(_:_:)"
}
-->

# backgroundPreferenceValue(_:_:)

Reads the specified preference value from the view, using it to
produce a second view that is applied as the background of the
original view.

```
nonisolated func backgroundPreferenceValue<Key, T>(_ key: Key.Type = Key.self, @ContentBuilder _ transform: @escaping (Key.Value) -> T) -> some View where Key : PreferenceKey, T : View
```

## Parameters

`key`

The preference key type whose value is to be read.

`transform`

A function that produces the background view from
the preference value read from the original view.

## Return Value

A view that layers a second view behind the view.

---

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)