最近在iOS14上使用 UITableViewHeaderFooterView 設(shè)置了背景色
self.contentView.backgroundColor = [UIColor whiteColor];
發(fā)現(xiàn)背景色下出現(xiàn)了一根線條

然后查看圖層,發(fā)現(xiàn)原來 UITableViewHeaderFooterView 層級有所變化


對比iOS14以下,多了一個 UISystemBackgroundView -> UIView , View顏色是灰色,查找一下api,發(fā)現(xiàn)iOS14增加了backgroundConfiguration 背景配置方法,如下我們把背景設(shè)置為透明
if (@available(iOS 14.0, *)) {
self.backgroundConfiguration = UIBackgroundConfiguration.clearConfiguration;
} else {
// Fallback on earlier versions
}