Sets a value to return for the given preference key when accessed by ancestors.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
func preference<K>(key _: K.Type = K.self, value: K.Value) -> some View where K : Preference Key