UITableView backgroundColor always white on iPad

后端 未结 16 1559
生来不讨喜
生来不讨喜 2020-12-07 21:35

I\'m working on a project. I have plenty of UITableViews which are set as clear color. Their views\' background color are set to my custom color and everything

16条回答
  •  一向
    一向 (楼主)
    2020-12-07 22:24

    Swift 3.1

    I've worked around this bug by placing this in my UITableViewCell subclass:

    When the cell is being loaded from the NIB file:

    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = UIColor.clear
    }
    

    and when the cell is being reused by the system

    override func prepareForReuse() {
        super.prepareForReuse()
        self.backgroundColor = UIColor.clear
    }
    

    iOS 10 is supposed to fix this issue in Interface Builder, as animeshporwal said.

提交回复
热议问题