Anybody trying to do this in swift then here is my code. Tiny and superb.
This trick works with even static cells where I don't use the cellForRowAtIndexPath method.
Sorry for little answer. Hope you know about datasource an delegates.
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row % 2) != 0{
cell.backgroundColor = UIColor .blackColor()
}else{
cell.backgroundColor = UIColor .lightGrayColor()
}
}
It will give you the result like...
