Discussion 議論
In most cases, labels show both their title and icon by default. However, some containers might apply a different default label style to their content, such as only showing icons within toolbars on macOS and iOS. To opt in to showing both the title and the icon, you can apply the title and icon label style:
Label("Lightning", systemImage: "bolt.fill")
.labelStyle(.titleAndIcon)
To apply the title and icon style to a group of labels, apply the style to the view hierarchy that contains the labels:
VStack {
Label("Rain", systemImage: "cloud.rain")
Label("Snow", systemImage: "snow")
Label("Sun", systemImage: "sun.max")
}
.labelStyle(.titleAndIcon)
The relative layout of the title and icon is dependent on the context it is displayed in. In most cases, however, the label is arranged horizontally with the icon leading.