【问题标题】:Swift UI Overlay a list to a background colorSwiftui 将列表叠加到背景颜色
【发布时间】:2020-02-09 04:20:01
【问题描述】:

我只想为我的列表设置一个颜色作为背景颜色。找不到任何有用的东西,

看起来不可能,我不想改变我行的每一种颜色。

任何提示如何做到这一点?看起来 SwiftUIList 不允许背景颜色,它只允许每个原始颜色。

struct ContentView: View {
    var body: some View {
        ZStack {
            RadialGradient(gradient: Gradient(colors: [.orange, .red]), center: .center, startRadius: 100, endRadius: 470).edgesIgnoringSafeArea(.all)
                .overlay(
                    List(0 ..< 5) { item in
                        Text("Test")
                    }
            )
        }
    }
}

【问题讨论】:

    标签: swift list uitableview swiftui swiftui-list


    【解决方案1】:

    你可以添加

    init() {
        UITableView.appearance().backgroundColor = .clear
        UITableViewCell.appearance().backgroundColor = .clear 
    }
    

    到您的结构,然后为您的列表设置背景。

    【讨论】:

      猜你喜欢
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      相关资源
      最近更新 更多