如何删除单元格的背景颜色? (如何自定义)

假设我想让单元格具有颜色或使单元格的边框更圆润或删除第一个单元格和第二个单元格之间的线,我将如何在 SwiftUI 中执行此操作?

如何删除单元格的背景颜色? (如何自定义)

struct TestView: View {
    init() {
            UITableView.appearance().backgroundColor = .clear
            UITableViewCell.appearance().backgroundColor = .green
        UITableViewCell.appearance()}
        var body: some View {
            LinearGradient(gradient: Gradient(colors: [Color.red,Color.purple]),startPoint: .top,endPoint: .bottom)
                .edgesIgnoringSafeArea(.vertical)
                .overlay(
                    List {
                        Group {
                            Text("Hallo")
                            Text("World")
                        }
                    }
                    .padding(50)
                    
            )
        }
chj950109 回答:如何删除单元格的背景颜色? (如何自定义)

您可以将 .listRowBackground 添加到您的列表中:

struct TestView: View {
init() {
        UITableView.appearance().backgroundColor = .clear
        UITableViewCell.appearance().backgroundColor = .green
    UITableViewCell.appearance()}
    var body: some View {
        LinearGradient(gradient: Gradient(colors: [Color.red,Color.purple]),startPoint: .top,endPoint: .bottom)
            .edgesIgnoringSafeArea(.vertical)
            .overlay(
                List {
                    Group {
                        Text("Hallo")
                        Text("World")
                    }.listRowBackground(Color.clear) //Add here
                }.padding(50)
                
                
                
        )
    }
本文链接:https://www.f2er.com/3345.html

大家都在问