删除列表中的黑色填充(SwiftUI)

问题描述 投票:0回答:2

这是我列表的代码:

import SwiftUI

struct PaymentScreen: View {

    var body: some View {
        return VStack (alignment: .center) {
            List (Terminal.terminals, id: \.self.distance) { terminal in
                PayTerminalAdapter(terminal: terminal).background(Color.white)
            }
        }
    }
}

我的列表的屏幕截图:

enter image description here

我无法删除列表元素之间的黑色开头和结尾填充以及填充。当我使用ForEach时(我有很长的端子排)-我对填充没有问题,但是填充效果如此缓慢,因此ForEach对我来说是一个不好的选择。如何删除列表中的黑色填充?

swift list listview swiftui padding
2个回答
0
投票

您应该为此更改.listRowBackground()


0
投票
import SwiftUI

struct PaymentScreen: View {

    init() {
        UITableView.appearance().separatorStyle = .none
        UITableViewCell.appearance().backgroundColor = .white
    }

    var body: some View {
        return VStack (alignment: .center) {
            List (Terminal.terminals, id: \.self.distance) { terminal in
                PayTerminalAdapter(terminal: terminal).background(Color.white)
            }
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.