Instance Method

padding(_:_:)

Pads the view using the specified edge insets.

Declaration

func padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View

Parameters

edges

The set of edges along which to inset this view.

length

The amount to inset this view on each edge. If nil, the amount is the system default amount.

Return Value

A view that pads this view using edge the insets you specify.

Discussion

The following example only pads the horizontal edge insets:

List {
    Text("Item 1")
}
.padding([.horizontal])

See Also

Adjusting the Padding of a View

func padding(CGFloat) -> View

Pads the view along all edge insets by the specified amount.

func padding(EdgeInsets) -> View

Pads the view using the specified edge insets.

struct EdgeInsets

The inset distances for the sides of a rectangle.