UITableView set background color

后端 未结 8 1520
离开以前
离开以前 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:22

    For SWIFT

    Thanks to @Irshad Qureshi I was able to get alternating background colors for my prototype cells by adding the following in my cellForRowAtIndexPath:

    if (indexPath.row % 2 == 0)
        {
            cell!.backgroundColor = UIColor.groupTableViewBackgroundColor()
        }
        else
        {
            cell!.backgroundColor = UIColor.whiteColor()
        }
    

提交回复
热议问题