Osa*_*eem 7 background list ios swiftui
我想更改列表的背景颜色。目前,我正在使用UITableView.appearance().backgroundColor更改颜色并且效果很好。但是,在 iOS 14 中,Apple 建议每个人都使用 collectionViews,我只是不知道我是否应该坚持下去。
我正在寻找其他方法来更改列表的背景颜色。问题是:我希望背景颜色与导航栏或测试行背景颜色相同,但我得到的是全黑背景。
在写作时,上面的UITableView.appearance().." in .onAppear' 我得到了想要的结果:
所以我的问题是,是否有更好的 iOS 14 方法来实现这一目标?
斯威夫特 5、Xcode 12、iOS 14
我可以使用Introspect库通过几行代码来完成此任务:
List {
...
}
.introspectTableView { tableView in
tableView.backgroundColor = .yellow
}
Run Code Online (Sandbox Code Playgroud)