【发布时间】:2020-09-21 02:02:47
【问题描述】:
SwiftUI 2 破坏了我的应用程序的一部分,该部分依赖于清晰的背景作为列表部分标题。以前我依靠这一行来使列表部分清晰。有谁知道如何在 SwiftUI 2 中实现这一点?
UITableViewHeaderFooterView.appearance().tintColor = .clear
这是一个适用于 SwiftUI 1 的示例:
struct ContentView: View {
var body: some View {
List {
Section(header:
Text("List Header")
) {
Text("Hi")
}
.listRowBackground(Color.clear)
}
.onAppear {
UITableViewCell.appearance().backgroundColor = UIColor.clear
UITableViewHeaderFooterView.appearance().tintColor = .clear
}
}
}
要求:List Header 应该是透明的而不是灰色的。
【问题讨论】:
-
我尝试了这个解决方案,但不幸的是,列表中没有运气:(
-
它确实工作,我刚刚检查过(除非我们谈论不同的事情) - 请添加Minimal, Reproducible Example。另请注意,您需要更改
UITableViewCell.appearance()。 -
添加了示例。不幸的是,Xcode 12/Swiftui 2 中的解决方案没有运气
-
不清楚您在谈论列表 header - 我添加了一种可能的解决方法来解决不清晰的颜色。但是在使用默认列表样式时,您可能无论如何都不应该使用清晰的颜色(因为文本重叠)。
标签: ios swiftui swiftui-list ios14