Structure¶
TitleOnlyLabelStyle¶
A label style that only displays the title of the label.¶
Declaration¶
struct TitleOnlyLabelStyle : LabelStyle
Overview¶
Use this label style to display a Label with a title only.
This is one of 3 default label styles. These are structs that conform to the LabelStyle protocol by implementing the makeBody(configuration:) function internally, so you don't have to do it yourself.
These are the default styles:
- DefaultLabelStyle, which displays the Label as-is
- IconOnlyLabelStyle, which displays the icon only
- TitleOnlyLabelStyle (this style), which displays the title only
All 3 styles have only one initializer, which takes no parameters.
To use a LabelStyle, pass it to a Label's labelStyle(_:) modifier:
struct ContentView: View {
var body: some View {
VStack {
Label("Banana", systemImage: "suit.heart.fill")
.labelStyle(DefaultLabelStyle())
Label("Banana", systemImage: "suit.heart.fill")
.labelStyle(IconOnlyLabelStyle())
Label("Banana", systemImage: "suit.heart.fill")
.labelStyle(TitleOnlyLabelStyle())
}
.font(.title)
}
}

Availability¶
iOS 14.0+
macOS 11.0+
tvOS 14.0+
watchOS 7.0+
Topics¶
Initializer¶
init() Creates a title-only label style.
Instance Method¶
makeBody(configuration:) Creates a view that represents the body of a label.
Type Alias¶
Body A view that represents the body of a label.