iOS 14带有两个新的单元配置:
UIContentConfiguration
顾名思义,内容配置可以帮助你操纵单元格的内容,例如图像,文本,辅助文本,布局指标和行为。
UIBackgroundConfiguration
可以帮助操纵背景颜色,视觉效果,笔触,插图和拐角半径。即使我们未指定默认设置,所有单元也会继承默认的后台配置。
要摆脱默认的iOS14白色背景,你需要按以下方式更改UITableViewCell
or UITableViewHeaderFooterView
backgroundConfiguration
// Add this code in your AppDelegate didFinishLauncingWithOptions
// or you can change configuration of certain subclass using self. backgroundConfiguration = ...
if #available(iOS 14.0, *) {
var bgConfig = UIBackgroundConfiguration.listPlainCell()
bgConfig.backgroundColor = UIColor.clear
UITableViewHeaderFooterView.appearance().backgroundConfiguration = bgConfig
//For cell use: UITableViewCell.appearance().backgroundConfiguration = bgConfig
}
阅读这篇文章以了解更多
这次真是万分感谢!