Generic Instance Method

overlayPreferenceValue(_:_:)

Returns a view that reads the value of preference Key from self, uses that to produce another view which is displayed as an overlay on self.

Declaration

iOS, watchOS
func overlayPreferenceValue<Key, T>(_ key: Key.Type = Key.self, _ transform: @escaping (Key.Value) -> T) -> some View where Key : PreferenceKey, T : View
macOS, Mac Catalyst, tvOS
func overlayPreferenceValue<Key, T>(_ key: Key.Type = Key.self, @ViewBuilder _ transform: @escaping (Key.Value) -> T) -> some View where Key : PreferenceKey, T : View

See Also

Responding to View Preferences

func onPreferenceChange<K>(K.Type, perform: (K.Value) -> Void) -> View

Adds an action to perform when the specified preference key’s value changes.

Beta
func backgroundPreferenceValue<Key, T>(Key.Type, (Key.Value) -> T) -> View

Returns a view that reads the value of preference Key from self, uses that to produce another view which is displayed as as the background to self.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software