iOS Swift - How to change background color of Table View?

前端 未结 6 1512
情书的邮戳
情书的邮戳 2021-01-31 02:46

I have a simple table view, I can change the colors of cells, but when trying to change the color of Table View (Background part) it is not working... I tried it via Storyboard.

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 03:29

    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        cell.contentView.backgroundColor = UIColor.yellowColor()
    }
    

    Swift 3

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        cell.contentView.backgroundColor = UIColor.yellow
    }
    

提交回复
热议问题