ios - 表格 View 末尾的巨大空白区域

标签 ios swift uitableview

我的牢房下方似乎有一个巨大的空旷不透明区域。当我向上滚动表格 View 时,我可以看到有一个不透明区域覆盖了表格 View 的亮橙色背景,如右侧屏幕截图所示。基于此question ,我尝试将 footerHeight 设置为 0 并将 footerView 设置为空 View ,但它没有用。有什么解决办法吗?

enter image description here enter image description here

代码

private func setupSongsTable() {
        let frame = CGRect(x: 0, y: 0, width: Screen.width, height: Screen.height)
        songsTable = UITableView(frame: frame, style: UITableViewStyle.plain)
        songsTable.sectionIndexBackgroundColor = UIColor.clear
        songsTable.backgroundColor = .orange
        songsTable.isOpaque = false
        songsTable.backgroundView = nil
        self.view.addSubview(songsTable!)
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        cell.backgroundColor = .blue
        return cell
}

最佳答案

尝试将 tableView.backgroundColor 设置为 .clear。如果这不起作用,请检查您的单元格的背景颜色是什么。 单元格背景颜色。从您的屏幕截图来看,您的单元格看起来像是白​​色背景色,而您的表格是默认的苹果浅灰色。

关于ios - 表格 View 末尾的巨大空白区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44992707/

相关文章:

ios - 更改UItabbar顶部边框线的默认颜色

ios - 如何在 iOS 8 中使用旋转

swift - iOS 13 自定义字体下载和安装

ios - 对 NSArray 的 JSON 响应以输出到 UITableView

ios - 如何在函数的返回类型中引用遵循协议(protocol)的类?

ios - AsyncDisplayKit 中的 Realm 导致终止 - Realm::In CorrectThreadException

iOS 不接收来自 Azure 通知中心的推送

swift - 属性更改时的动画 View SwiftUI

ios - 为什么 UITableView 在我有 2 个额外的行之前不滚动?

iPhone:获取结果 Controller ,不要使用 UITableView 中的部分