在iOS 16的新 SwiftUI
更新中,List
不再依赖于 UITableView
。因此,我们曾经用来将 List
背景色设置为 .clear
的以下代码段现在已经无用:
UITableView.appearance().backgroundColor = .clear
我看到有人使用 introspect
解决了这个问题,但是否有其他更简洁的方法可以实现相同的行为呢?
另外请注意,在 macOS
上,以下代码可以正常运行(已在 Xcode 14 beta
和 macOS Ventura
中测试):
extension NSTableView {
open override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
backgroundColor = NSColor.clear
enclosingScrollView!.drawsBackground = false
}
}
backgroundColor
getter 时,我失去了我的listRowSeparatorTint
(正如您的图片所示)。有什么办法可以恢复它吗? - Darren.scrollContentBackground
可以使一切正常工作,无需使用这种解决方法和不同颜色的分隔符。 - DarrenscrollContentBackground
和Style
。它应该被设置为.hidden
,然后与.background(style)
组合使用。 - Jay Lee