Instance Method インスタンスメソッド

badge(_:)

Generates a badge for the view from an integer value.

Declaration 宣言

func badge(_ count: Int) -> some View

Parameters パラメータ

count

An integer value to display in the badge. Set the value to zero to hide the badge.

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")
}