如何通过自定义ListStyle删除列表中的单独行?

时间:2019-12-19 06:56:34

标签: swiftui

我想删除行之间的分隔线。如何实现我的自定义样式?

struct CustomListStyle: ListStyle {
    static func _makeView<SelectionValue>(value: _GraphValue<_ListValue<CustomListStyle, SelectionValue>>, inputs: _ViewInputs) -> _ViewOutputs where SelectionValue : Hashable {
        // ???
    }

    static func _makeViewList<SelectionValue>(value: _GraphValue<_ListValue<CustomListStyle, SelectionValue>>, inputs: _ViewListInputs) -> _ViewListOutputs where SelectionValue : Hashable {
        // ???
    }
}

struct ListDemo: View {
    @State var list = ["Row 1", "Row 2"]

    var body: some View {
        List {
            ForEach(list, id: \.self) {
                Text($0)
            }
        }.listStyle(CustomListStyle())
    }
}

我知道如何通过调用UITableView.appearance().separatorStyle = .none来实现这一点,但我想进一步了解ListStyle协议。什么是_GraphValue或`_ViewInputs,_ViewOutputs?

0 个答案:

没有答案