如何更改SwiftUI和iOS 14中的单元格背景颜色?
在我的iOS应用程序中,我有SwiftUI列表。在iOS 14之前,将其放入AppDelegate可更改单元格的背景颜色:如何更改SwiftUI和iOS 14中的单元格背景颜色?,ios,swift,swiftui,Ios,Swift,Swiftui,在我的iOS应用程序中,我有SwiftUI列表。在iOS 14之前,将其放入AppDelegate可更改单元格的背景颜色: UITableViewCell.appearance().backgroundColor = .black 在iOS 14之后,这不再改变颜色,它已恢复为默认白色 这也不起作用: UITableViewCell.appearance().backgroundConfiguration?.backgroundColor = .black 在iOS 14中,是否有其他方法可
UITableViewCell.appearance().backgroundColor = .black
在iOS 14之后,这不再改变颜色,它已恢复为默认白色
这也不起作用:
UITableViewCell.appearance().backgroundConfiguration?.backgroundColor = .black
在iOS 14中,是否有其他方法可以更改SwiftUI中UITableViewCell的颜色?您需要对单元格使用listRowBackground修改器,并且仍然可以对整个表视图背景使用外观,如下图所示 使用Xcode 12/iOS 14进行测试
init(){
UITableView.appearance().backgroundColor=UIColor.yellow
}
var body:一些观点{
名单{
ForEach(0..这很有效!有没有办法更改分隔符颜色?
init() {
UITableView.appearance().backgroundColor = UIColor.yellow
}
var body: some View {
List {
ForEach(0..<5, id: \.self) {
Text("Hello \($0)").foregroundColor(.blue)
}.listRowBackground(Color.black)
}
}