首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS14中表节标题中的白色背景

iOS14中表节标题中的白色背景
EN

Stack Overflow用户
提问于 2020-10-14 14:09:55
回答 4查看 2.9K关注 0票数 11

这一问题是在“建筑到iOS14xcode12”之后出现的。

我有一个具有透明背景的节标题,在iOS14上,随着新的_UISystemBackgroundView添加到层次结构中,它变成白色。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2020-10-14 14:09:55

iOS 14提供了新的两种单元配置:

  1. 内容配置. UIContentConfiguration

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

  1. 背景配置 UIBackgroundConfiguration

可以帮助操纵背景颜色,视觉效果,笔画,镶嵌和角半径。所有单元格都将继承默认的背景配置,即使我们没有指定一个。

解决方案

要摆脱默认的iOS14白色背景,需要按以下方式更改UITableViewCellUITableViewHeaderFooterView backgroundConfiguration

代码语言:javascript
复制
    // 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
    }

阅读这篇文章以获得更多信息

票数 19
EN

Stack Overflow用户

发布于 2020-12-04 07:12:35

UITableViewHeaderFooterView / UITableViewCell自定义类中-使用实现示例重写下一个方法:

Swift:

代码语言:javascript
复制
@available(iOS 14.0, *)
override func updateConfiguration(using state: UICellConfigurationState) {
    backgroundConfiguration = UIBackgroundConfiguration.clear()
}

目标-C:

代码语言:javascript
复制
- (void)updateConfigurationUsingState:(UICellConfigurationState *)state {
    self.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];
}
票数 8
EN

Stack Overflow用户

发布于 2020-12-03 15:43:22

目标-C版@Husam溶液:

代码语言:javascript
复制
if (@available(iOS 14.0, *)) {
    UIBackgroundConfiguration *bgConfig = [UIBackgroundConfiguration listPlainCellConfiguration];
    bgConfig.backgroundColor = UIColor.clearColor;
    [UITableViewHeaderFooterView appearance].backgroundConfiguration = bgConfig;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64355156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档