Customizing your widget’s view
At present, your widget displays the restaurant’s name and cuisines in white text on the Lock screen. You’ll configure the widget to improve its appearance. Click LetsEatWidget.swift
in the Project navigator and modify the LetsEatWidgetEntryView
structure as follows:
struct LetsEatWidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
ZStack {
AccessoryWidgetBackground()
VStack {
Text(entry.restaurantTitle)
.font(.headline)
Text(entry.restaurantSubtitle)
.font(.body)
}
}
}
}
Let’s break this down:
Zstack {
AccessoryWidgetBackground()
A Zstack
view overlays and aligns all its child views. The AccessoryWidgetBackground()
child view gives the widget a background.
Text(entry.restaurantTitle)
.font(.headline)
This sets the text properties for the restaurant title text view. .font...