ios - 设置uitableview背景 View

标签 ios swift uitableview

我想为我的tableview设置背景 View ,

 override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let backgroundView = BackgroundGradient(frame: self.view.frame)
    self.tableView.backgroundView = backgroundView
}

但是背景仍然是白色(应该是蓝色渐变)。我试图在 View 中设置它并加载,结果相同,我更改为背景颜色以清除,但仍然没有。我错过了什么?

最佳答案

您的 UITableViewCell 可能会遮挡您表格的 backgroundView。尝试将单元格的背景颜色设置为清除。

引自 Apple 文档 (https://developer.apple.com/reference/uikit/uitableview/1614986-backgroundview)

You must set this property to nil to set the background color of the table view.

关于ios - 设置uitableview背景 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44216329/

相关文章:

ios - 数据选择器为一个字段正确填充但不是另一个

ios - 如何将静态 UITableView 设置为 UIView 的 subview ?

iphone - 如何在其他应用程序中集成 aurioTouch 应用程序功能?

javascript - 如何让什么菜单自动关闭?

ios - 如何在模型中搜索数组属性

Swift CollectionView 垂直分页

ios - Ios 中 TableView 中的动画

ios - 当存在图像时,为什么我的 tableview 单元格不能正确调整大小?

iphone - 通过 NSRegularExpression 获取 Javascript 函数之间的特定值?

ios - UIActivityViewController 在电子邮件或文本而非 fb 或 Twitter 时卡住