How to remove the left and right Padding of a List in SwiftUI?

后端 未结 6 2035
情歌与酒
情歌与酒 2020-12-14 06:21

How to remove the left and right Padding of a List in SwiftUI? Every List i create has borders to the leading and trailing of a cell.

What modifier should I add to r

6条回答
  •  渐次进展
    2020-12-14 06:53

    Use this modifier:

    .listRowInsets(EdgeInsets(....))
    

    However, as stated in the documentation, the insets will be applied to the view when inside a list.

    Sets the inset to be applied to the view when placed in a list. (emphasis mine)

    Using this modifier on the List itself will have no effect on the views inside it. You must use the modifier on the view inside the List for the modifier to have an effect.

    Example usage:

    List {
        Text("test")
            .listRowInsets(EdgeInsets(top: -20, leading: -20, bottom: -20, trailing: -20))
    }
    

提交回复
热议问题