placeholder(in:)
Provides a timeline entry representing a placeholder version of the widget.
Declaration
func placeholder(in context: Self.Context) -> Self.EntryParameters
- context:
An object that describes the context in which to show the widget.
Return Value
A timeline entry that represents a placeholder version of the widget.
Discussion
When WidgetKit displays your widget for the first time, it renders the widget’s view as a placeholder. A placeholder view displays a generic representation of your widget, giving the user a general idea of what the widget shows. WidgetKit calls placeholder(in:) to request an entry representing the widget’s placeholder configuration. For example, the game status widget would implement this method as follows:
struct GameStatusProvider: TimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
GameStatusEntry(date: Date(), gameStatus: "—")
}
}In addition, WidgetKit may render your widget as a placeholder if user’s choose to hide sensitive information on Apple Watch or the iPhone Lock Screen. To learn more about redacting sensitive data, see Creating a widget extension.