How to remove the line separators from a List in SwiftUI without using ForEach?

前端 未结 13 1759
盖世英雄少女心
盖世英雄少女心 2021-01-30 04:50

I have this code to display a list of custom rows.

struct ContentView : View {
    var body: some View {
        VStack(alignment: .leading) {
            List(1         


        
13条回答
  •  一向
    一向 (楼主)
    2021-01-30 05:23

    I'm not sure if you need all the functionality of "UITableView" in SwiftUI, but if you just want to just display a list of views in iOS 13 or later couldn't you just do:

    ScrollView {
        VStack(alignment: .leading) {
            ForEach(1...10) { _ in
                CustomRow()
            }
        }
    }
    

    And then add .padding() for any margins you want?

提交回复
热议问题