I have a UITableView
with two sections, section 0
contains 1
row and section 1 contains two rows. My Question how can i set two colors to alternative row.I tried the fallowing way but section0
first row and section1
first row shows same same color.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell==nil)
{
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
if(indexPath.row%2==0)
{
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Light.png"]];
}
else
{
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Dark.png"]];
}
return cell;
}