swift - iOS14 中表格部分标题中的白色背景

标签 swift xcode uitableview ios14 xcode12

建到后出现这个问题iOS14 xcode12 .
我有一个透明背景的部分标题,在 iOS14 上它变成白色,新 _UISystemBackgroundView添加到层次结构中。

最佳答案

iOS 14 带有两个新的单元格配置:

  • 内容配置。 UIContentConfiguration

  • 顾名思义,内容配置可以帮助您操作单元格的内容,如图像、文本、辅助文本、布局指标和行为。
  • 后台配置 UIBackgroundConfiguration

  • 可以帮助处理背景颜色、视觉效果、笔触、插图和圆角半径。即使我们没有指定,所有单元格都会继承默认的背景配置。
    解决方案
    要摆脱默认的 iOS14 白色背景,您需要更改 UITableViewCellUITableViewHeaderFooterView后台配置如下
        // 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
        }
    
    阅读 this article更多

    关于swift - iOS14 中表格部分标题中的白色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64355156/

    相关文章:

    ios - 一个 Storyboard多个 viewController 或多个 Storyboard每个都有一个 viewController 哪个更可取?

    ios - 如何本地化 Cordova iOS 项目?

    ios - 使用来自另一个操作的现有展开转场

    ios - 如何在不使用标签的情况下更改 tableviewCell 中的图像按钮

    swift - 区分 Swift 协议(protocol)中继承的 `associatedtype`

    ios - 只要函数持续就显示 UIAlertController

    iphone - 替代已弃用的 UITableViewCell setText?

    ios - 如何匹配两个TableView中的值

    swift - swift 中符合多种协议(protocol)的类型

    swift - 无法在 View Controller 上创建 UIBarButtonItem