跳转至
Structure

InsetListStyle

The behavior and appearance of an inset list.

Declaration

struct InsetListStyle : ListStyle

Overview

Use the listStyle(_:) modifier to apply this list style to a List. This style creates a gap between the borders of the list and the edge of the screen:

struct ExampleView: View {
    var body: some View {
        List {
            Text("Bananas 🍌🍌")
            Text("Apples 🍎🍎")
            Text("Peaches 🍑🍑")
        }
        .listStyle(InsetListStyle())
    }
}
A view displaying an inset list with three items "Bananas 🍌🍌", "Apples 🍎🍎", and "Peaches 🍑🍑"; the list items and the thin gray lines that separate them sit condensed in the center of the view, creating a gap between the list and the edges of the frame.

Availability

iOS 14.0+

macOS 11.0+

Topics


Initializer

init() Creates an inset list style.