In my app, I want to display multi-column tableView in iPad.
So, I used a cocoa control from :MultiColumn TableView
it works fine for me, But I want to display the rows in alternate color.
For this, I am not able to find where I change the code for it.
- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath
{
if(indexPath.row % 2 == 0)
cell.backgroundColor = [UIColor redColor];
else
cell.backgroundColor = [UIColor whiteColor];
}
use the indexPath in the cellForRowAtIndexPath
to get the desired results.
if( [indexPath row] % 2){
cell.backgroundColor=[UIColor whiteColor];
}
else{
cell.backgroundColor=[UIColor purpleColor];
}
You will have this delegate method in the class which is implementing the UITableViewDelegate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With