overlayPreferenceValue

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

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+

Overloads

2 ways to call compose().overlayPreferenceValue(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().overlayPreferenceValue(
  key: string,
  transform: ReactNode | ((arg0: any) => ReactNode)
)
Swift
nonisolated func overlayPreferenceValue<Key, T>(
    _ key: Key.Type = Key.self,
    @ContentBuilder _ transform: @escaping (Key.Value) -> T
) -> some View
where Key : PreferenceKey, T : View

Parameters

  • key*string

    The preference key type whose value is to be read.

  • transform*ReactNode | ((arg0: any) => ReactNode)

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

Return value

A view that layers a second view in front of the view.

See also

More in Preferences.