An integer value to display in the badge. Set the value to zero to hide the badge.
Instance Method
インスタンスメソッド
badge(_:)
Generates a badge for the view from an integer value.
Availability 有効性
- iOS 15.0+
- iPadOS 15.0+
- macOS 12.0+
- Mac Catalyst 15.0+
Technology
- Swift
UI
Declaration 宣言
Parameters パラメータ
count
Discussion 議論
This modifier automatically formats the integer with a formatter appropriate for the current Environment
.
Badges are only displayed in list rows and iOS tab bars.
The following example shows a List with a badge on one of the rows:
List {
Text("Recents")
.badge(10)
Text("Favorites")
}