UITableView set background color

后端 未结 8 1506
离开以前
离开以前 2020-12-24 02:51

I change the background color of the UITableViewCells in the tableView:cellForRowAtIndexPath method

    if(indexPath.row % 2 == 0){
        cell.bac         


        
8条回答
  •  孤独总比滥情好
    2020-12-24 03:32

    In swift, you can change tableview background color or you can set image to tableview background color like this;

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png")!)
        self.tableView.backgroundColor = UIColor.clearColor()
    }
    
    
    //    change cell text color and background color
    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
            cell.backgroundColor = UIColor.clearColor()
    }
    

提交回复
热议问题